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

How to run multiple javascripts in one pdf fillable form

New Here ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

I've built 3 different javascripts for my fillable pdf document for 3 different sets of boxes, but it will only run one of those scripts and the other two won't work. How can I get all 3 to work on the same pdf? I'm using a drop down in each of the 3 boxes that will then populate 4 other boxes with information using a javascript (see picture below...this is one of the 3). But again, it will only work on one of the three.

Any help would be most appreciated!

Cambria5CAC_0-1612455433186.png

 

TOPICS
JavaScript , PDF forms

Views

1.1K

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 Expert ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

What script does you use? Where does you use the script?

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
New Here ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

I've placed 'x' where numbers would normally be in my script to protect the information.

var data =

{items:[

        {key : "North Direct", value1 : "RX: xxx.xxxx", value2 : "RX Tone 000.0", value3 : "TX: xxx.xxxx", value4 : "TX Tone 000.0"},

        {key : "Deadman RPT", value1 : "RX: xxx.xxxx", value2 : "RX Tone 000.0", value3 : "TX: xxx.xxxx", value4 : "TX Tone xxx.x"},

        {key : "Jelm RPT", value1 : "RX: xxx.xxxx", value2 : "RX Tone 000.0", value3 : "TX: xxx.xxxx", value4 : "TX Tone xxx.x"},

        {key : "Buckhorn RPT", value1 : "RX: xxx.xxxx", value2 : "RX Tone 000.0", value3 : "TX: xxx.xxxx", value4 : "TX Tone xxx.x"},

        {key : "Little Gravel RPT", value1 : "RX: xxx.xxxx", value2 : "RX Tone 000.0", value3 : "TX: xxx.xxxx", value4 : "TX Tone xxx.x"}

       ]

};

 

function SetCommandFieldValues(value){

    for(i=0; i<data.items.length; i++){

        if(data.items[i].key === value){

            this.getField("CommandRX").value = data.items[i].value1;

            this.getField("CommandRXTone").value = data.items[i].value2;

            this.getField("CommandTX").value = data.items[i].value3;

            this.getField("CommandTXTone").value = data.items[i].value4;

        }

    }

}

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
New Here ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

The above code is within the document javascripts box.

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 Expert ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

This defines a variable and a function. Where does you use the function?

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
New Here ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

I use a custom keystroke script in the properties of the drop down.

if( event.willCommit ) {
if(event.value == "" || event.value == "Select One") this.resetForm(["CommandRX","CommandRXTone","CommandTX","CommandTXTone"]); else SetCommandFieldValues(event.value);
}

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 Expert ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

Does you use the same at all dropdowns?

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
New Here ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

Yes, but with different values, keys, and field names. All are unique to a certain set of boxes. And I've named the scripts differently as well.

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 Expert ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

Check the console for errors.

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
New Here ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

No errors are displaying.

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
New Here ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

Is it actually possible to run 3 scripts on the same file or not? All the scripts are exactly the same except the field names, values, and keys. I've just copied and pasted and changed the values/names/keys to what should be displayed with each drop down option.

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 Expert ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

You must also use different functions.

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
New Here ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

So I can't use this function at the end of each script, but change the names? So it would be SetAirAirFieldValues and SetAirGroundFieldValues for the other two scripts. 

 

function SetCommandFieldValues(value){

    for(i=0; i<data.items.length; i++){

        if(data.items[i].key === value){

            this.getField("CommandRX").value = data.items[i].value1;

            this.getField("CommandRXTone").value = data.items[i].value2;

            this.getField("CommandTX").value = data.items[i].value3;

            this.getField("CommandTXTone").value = data.items[i].value4;

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
LEGEND ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

"So I can't use this function at the end of each script, but change the names?" I don't think you're telling us everything about what scripts you have, and where they are. But I can say for sure that there is only one function with a given name. The function is available everywhere, not just in its own box. So if you are duplicating a function and hoping to have three different ones with the same name it won't work. 


There should be no problem with using a different named function for each box. But then, why even have a function?

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 Expert ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

You can't use the same name for 3 different functions.

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
New Here ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

LATEST

It works now...just had to have different names for the data. So data.items, data1.items, and data2.items.

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