Need to place 10 barcodes on a page.
The barcode position are random.
The barcode values and X-Postion + Y Postion are delivered by the datamapper
I have placed 10 barcodes on the page, with the values from datamapper Barcode1 - Barcode10
I have added a script which control the Barcode.
The script can turn the Barcode on an off - if it is not present.
I have also tried to move the barcode position with the script, but it is not working.
Can anyone see what I’m doing wrong in the script.
Barcode1_X_Value holds the X position in the datamapper in mm x 100
Barcode1_X_Value holds the Y position in the datamapper in mm x 100
I have tried to replace XPos+YPos in the script with just values - same result barcode is not moving around.
Don’t worry. I had to learn javascript coming from PP7 to Connect. I don’t claim to be an expert. I have not done positioning like this in a while and the answer was staring me in the face.
results.css('position', 'relative');
And you have your x/y backwards
EDIT: My final script. I added data to the template using counters. File-Add data-Generate Counters. I added a code 39 barcode to my template. It has an ID with value barcode. I opened the barcode script that Connect adds to the scripts pane and selected Expand to edit the code within the script.
var field, result = "";
if (record.fields.Counter == "") {
results.attr("data-conditional", "");
results.hide();
}else{
field = record.fields["Counter"];
result += field;
results.text(result);
results.css("position", "relative");
var XPos = 3000 / 100;
var YPos = 5000 / 100;
results.css("top", YPos + 'mm').css("left",XPos + 'mm');
results.show();
}
Thanks it is almost working.
But how do I control each barcode position with the script ?
Thought that when put in Top, Left in the script it took the x,y from the top of the page 0mm,0mm
But it is not, I can see that if i change the height of one barcode it changes the position of the rest of the barcodes. So it looks lige each barcode is controlling the next one. It should not do that.
If you want to control all 10 barcodes you need 10 scripts. I don’t know of a way to have one script to control all barcodes. That is why I mentioned the barcode ID matching the scripts selector. (They are married) So in my mind you could have gone two ways. 1. Created 10 scripts that only control the barcodes x/y etc. (that is 10 barcode scripts added by Connect and 10 scripts you manually added to the scripts pane and entered each barcodes matching ID in the selector box e.g. #barcode) or 2. You Expanded all 10 barcode scripts and modified their codes. Judging by your script above it looks like the latter.
I don’t think it is possible to only have one script. I could be wrong but only OL will be able to advise that.
EDIT: I see you have it working before I replied. Did you use multiple scripts or one? Just curious