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

124

Likes

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
Adobe Community Professional ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

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

Likes

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;

        }

    }

}

Likes

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.

Likes

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
Adobe Community Professional ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

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

Likes

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);
}

Likes

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
Adobe Community Professional ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

Does you use the same at all dropdowns?

Likes

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.

Likes

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
Adobe Community Professional ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

Check the console for errors.

Likes

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.

Likes

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.

Likes

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
Adobe Community Professional ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

You must also use different functions.

Likes

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;

Likes

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
Most Valuable Participant ,
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?

Likes

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
Adobe Community Professional ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

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

Likes

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.

Likes

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