Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
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

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
3.2K
Translate
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
1 ACCEPTED SOLUTION
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.

View solution in original post

Translate
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

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.

Translate
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

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

Translate
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

Are you sure you want to change the default value, and not just the selected value?

Translate
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

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?

Translate
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

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";

 

Translate
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

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

 

Thanks once again 🙂

Translate
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

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 

 

 

Translate
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

Where does it not work?

Translate
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

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.

Translate
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
LATEST

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

Translate
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