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

Complicated Populating Check Boxes and Text Boxes

Community Beginner ,
Dec 27, 2018 Dec 27, 2018

Copy link to clipboard

Copied

Ok so I have a situation where I have Checkboxes and textboxes that are related and need to populate together to a single textbox  BUT I have another set of checkboxes and textboxes that are related that ALSO need to populate together to the SAME single textbox mentioned previously. So here are the separate java scripts for each set of data that I want to put into the same single text box. How do I join the scripts together? or is it possible?

Script 1:

var values = []; 

for (var i=280; i<=281; i++) { 

    var fname = "CheckBox "+i; 

    var f = this.getField(fname); 

    if (f==null) { 

        console.println("Error! Can't find: " + fname); 

        continue; 

    } 

    if (f.valueAsString!="Off") values.push(f.valueAsString); 

}

if (this.getField("SLS EO").valueAsString!="") values.push("SLS EO: " + this.getField("SLS EO").valueAsString);

if (this.getField("SLS EC").valueAsString!="") values.push("SLS EC: " + this.getField("SLS EC").valueAsString);

event.value = values.join(", ");

Script 2:

var values = []; 

for (var i=282; i<=283; i++) { 

    var fname = "CheckBox "+i; 

    var f = this.getField(fname); 

    if (f==null) { 

        console.println("Error! Can't find: " + fname); 

        continue; 

    } 

    if (f.valueAsString!="Off") values.push(f.valueAsString); 

}

if (this.getField("WS Time").valueAsString!="") values.push("WS Time: " + this.getField("WS Time").valueAsString);

event.value = values.join(", ");

TOPICS
Acrobat SDK and JavaScript , Windows

Views

280

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
LEGEND ,
Dec 27, 2018 Dec 27, 2018

Copy link to clipboard

Copied

It's certainly possible, but you haven't said how you want the output to look exactly. A simple merging of the scripts could be:

Those look like calculate scripts, so all you'd need to so is something like:

var values = [];

for (var i = 280; i <= 283; i++) {

    var fname = "CheckBox " + i;

    var f = this.getField(fname);

    if (f == null) {

        console.println("Error! Can't find: " + fname);

        continue;

    }

    if (f.valueAsString != "Off") values.push(f.valueAsString);

}

if (this.getField("SLS EO").valueAsString != "") values.push("SLS EO: " + this.getField("SLS EO").valueAsString);

if (this.getField("SLS EC").valueAsString != "") values.push("SLS EC: " + this.getField("SLS EC").valueAsString);

if (this.getField("WS Time").valueAsString != "") values.push("WS Time: " + this.getField("WS Time").valueAsString);

event.value = values.join(", ");

Votes

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
Community Beginner ,
Dec 28, 2018 Dec 28, 2018

Copy link to clipboard

Copied

LATEST

ok so I need the info from check box 280 and 281 and text boxes "SLS EO" and "SLS EC" to be populate to the text box "Text 4" and the information to stay together/sequentially next to each other as they are related and then Check box 282 and 283 and text box "WS Time" to populate together/sequentially in the "Text 4". 

so in the text box "Text 4" the info would be in this order

checkbox 280, checkbox 281, SLS EO, SLS EC, Checkbox 282, Checkbox 282, WS Time.

Does this make sense?

Votes

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