I’m trying to create a template that will positon a barcode on the page based on a value in the data. I can get the values in no problem but I can’t figure out how to actually move the barcode.
I was given this code from OL support:
var locx = 100;
var locy = 100;
var temp = ‘"<div anchor=“page_media_0"style=“position: absolute; overflow: hidden; box-sizing: border-box; width: 200px; height: 200px; top: 33.16319676293945px; left: 74.20320476293945px;” offset-x=”’+locx +‘" offset-y="’+locy +‘“>”’;
where 100 would be the position variable. I’ve then added that to the script for the barcode but it doesn’t seem to do anything. Below is a screenshot the script now for barcode
I guess–based on the shared screenshot of the “barcode” Standard Script–it’s because you’re not replacing the element with the value of the variable “temp”. To do so you need to use the method replaceWith( content ), like:
results.replaceWith( temp );
But a better idea will be to replace the “temp” variable with the attr( "attributeName", "value" ) method, by which you can change the values of attribute “offset-x” and “offset-y”, for example:
The reason why this doesn’t work is because you’re using “Text” as selector. Which mean that you’re trying to change the position of the text (element) “@SecurityCodeSubsPage@”. Instead of that you need to choose the “Selector”.
May I know which version of PReS Connect you’re using?
When I use the following Standard Script in combination with a Positioned Box element I’m able to change the position and the content of the Positioned Box element:
Selector: #example
Script:
var field = "", result = "";
results.attr( "offset-y", "96" );
results.attr( "offset-x", "96" );
field = "Hello World"; //record.fields[ "SecurityCodeFirstPage" ];
if ( field !== "" ) result += field;
results.html( result );