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

794

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

correct answers 1 Correct answer

Adobe Community Professional , 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.

Likes

Translate

Translate
Adobe Community Professional ,
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.

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

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 ,
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?

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
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?

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

 

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
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 🙂

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

 

 

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

Copy link to clipboard

Copied

Where does it not work?

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 ,
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.

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 ,
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...

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