• 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 change value of dropdown list with a click of a button in adobe form javascript

Community Beginner ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

HI all,

I've created a items dropdown menu in adobe form.

 

the name of a drop down list is "Header" which contains items as under,

2inch header

2.5inch header

3inch header 

4 inch header

 

Now I have created a button named "3inch header". If i click on this button then the default value of "Header" dropdown changed to "3inch header" 

how can i do this with javascript in adobe  form?

 

pls help

TOPICS
Create PDFs , Edit and convert PDFs , JavaScript , PDF forms , Standards and accessibility

Views

1.7K

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

correct answers 1 Correct answer

Community Expert , May 12, 2022 May 12, 2022

In "PG" field value is "Pressure Gauge " and in your script it's "Pressure Gauge" whitout space at the end, you can just add space in your script to make it work.

Votes

Translate

Translate
Community Expert ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

You must reorder the items of the dropdown when you want change the default value.

The first entry in the list is the default 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 Beginner ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

Hi there,

thanks for the prompt reply. But Can u elaborate a little and guide how can i do it ?

 

I am totaly new to this .

 

 

Thanks

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 ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

Are you sure you want to change the default value, and not just the selected 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 Beginner ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

no i want to change the selected value, not the default value. its my mistake. 

 

I want to change value of drop down list every time i press the button 

 

 

any help?

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 ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

What do you mean by "every time I press button"? Do you want it to cycle through the values of the drop-down, or to apply a specific value when the button is clicked?

The latter is very simple:

 

this.getField("Header").value = "3inch header";

 

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 ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

Thanks it works, actually i was doing spell mistake.. but now everything works fine. 

 

Thanks once again 🙂

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 ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

I've added below javascript lines in a button,

 

this.getField("Header").value = "Header Assembly (PP)";
this.getField("Filter 1").value="Screen Filter";
this.getField("Filter 2").value="Hydrocyclone Filter";
this.getField("Fertigation Unit").value="Ventury Injector";
this.getField("Bypass Valve-1").value="Butterfly Valve";
this.getField("Bypass Valve -2").value="PP Ball Valve FE";
this.getField("Bypass Tee").value="Bypass Tee (PP)";
this.getField("PG").value="Pressure Gauge";
this.getField("ARV").value="Air Release Valve";
this.getField("Text5.0.0").value="3Inch";
this.getField("Text5.1.0").value="3Inch";
this.getField("Text5.2.0").value="3Inch";

but it not works for all the fiedls, is there any restrictions of lines in javascripts?

 

I've also attached my pdf file for your reference. please take a look and reply 

 

thanks 

 

 

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 ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

Where does it not work?

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 ,
May 12, 2022 May 12, 2022

Copy link to clipboard

Copied

In "PG" field value is "Pressure Gauge " and in your script it's "Pressure Gauge" whitout space at the end, you can just add space in your script to make it work.

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 ,
May 12, 2022 May 12, 2022

Copy link to clipboard

Copied

LATEST

There is a limit to the length of a script, but you're nowhere near it...

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