• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Combine 2 Text fields and Checkbox Value then populate within text field

New Here ,
Oct 19, 2017 Oct 19, 2017

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!

TOPICS
Acrobat SDK and JavaScript

Views

206

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation