Copy link to clipboard
Copied
Hello!
I am trying to combine two text fields and a check box value into a line of its own within a text field.
Clients are able to select one of 7 color options (Check Box1), 1 of 200 text options (Message Number_01) and the location (Location01) for 1 complete product. There are 81 total products. I need these options for each product to populate on a summary page within a text field with the "Off" on the check box to remove that line. Each of these three options should concatenate onto one line
Example:
PP012 Pink Message # 101 (25)
PP058 Green Message # 25 (Wall 3)
Here is the basic script I was trying to use:
// Get the field values, as strings
var s1 = getField("Check Box1").valueAsString + " " + "Message #" + getField("Message Number_01").valueAsString + "Location" + getField("Location01").valueAsString;
var s2 = getField("Check Box2").valueAsString + " " + "Message #" + getField("Message Number_02").valueAsString + "Location" + getField("Location02").valueAsString;
// array of field names to process;
var aFieldNames = new Array(s1, s2);
// array for non-"Off" values;
var aValues = new Array();
// loop through the fields and add the non-"Off" filed values to the array;
for(var i = 0; i < aFieldNames.length; i++) {
if(this.getField(aFieldNames).valueAsString != "Off") aValues.push(this.getField(aFieldNames).valueAsString);
} // end loop processing field values;
// set the value of the text field to the concatenated non-"Off" field values;
event.value = aValues.join("\n");
Thanks!
Have something to add?