Skip to end of metadata
Go to start of metadata

Description

This sample script selects an image based upon a field value using a nested if statement.

The script evaluates the value for the field "country" and specifies the certification image that should be used for the image field "cert_image".  If the value of "country" does not match the defined values, no image is printed.

Fields required on the label

NameTypeData source
countryvariable textkeyboard
script_fieldvariable textscriptscript
cert_imageimageIkeyboard


Create a label with the above fields, then enter the following code for the script_field script.

var input =(label.fields.field.(@name == 'country').@data);  
if(input == "USA")  
{
  label.fields.field.(@name == 'cert_image').@data="ETL300.PCX";  
}  
else if(input == "France")  
{
  label.fields.field.(@name == 'cert_image').@data="CE.PCX";  
}  
else if(input == "Spain")  
{
  label.fields.field.(@name == 'cert_image').@data="CE.PCX";  
}  
else if(input == "Canada")  
{
  label.fields.field.(@name == 'cert_image').@data="CSA300.PCX";  
}  
else  
{
  label.fields.field.(@name == 'cert_image').@data="";  
} 

 

Related Articles

 

Article Number

 2008014

Versions

 All supported Loftware versions

Environment

All supported installation environments.