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

Dropdown to hide/show multiple fields and change their values

New Here ,
Apr 22, 2025 Apr 22, 2025

On my Form, I have a dropdown with three items in the list, (Option1, Option2, and Option3) that I want to affect two text boxes, Text1 and Text2.  Option2 in the dropdown has an Export Value of 200.00, Option3 has an Export Value of 350.00

 

Option1 is the default selection of the dropdown, and with Option1 I want:

Text1 to be visible and be a regular text field that the user can edit themself, and

Text2 to be hidden and have a value of 0.00

 

If the user selects Option2, I want:

Text1 to be hidden and have a value of 0.00, and

Text2 to become visible and show the Export Value of Option2 (200.00)

 

If the user selects Option3, I want:

Text1 to be hidden and have a value of 0.00, and

Text2 to become visible and show the Export Value of Option3 (350.00)

 

I don't know anything about script writing, I usually just copy-paste scripts that others have posted online, but I haven't found anything yet that meets these requirements.  Any help is greatly appreciated, thank you!

TOPICS
JavaScript , PDF forms
153
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 ,
Apr 22, 2025 Apr 22, 2025

Since you have export values and if you want to use validation script, then do like this:

var t1 = this.getField("Text1");
var t2 = this.getField("Text2");

if(event.value == "Option1"){
 t1.display = display.visible;
 t2.display = display.hidden;
 t2.value = "";}
else if(event.value == "Option2"){
 t1.display = display.hidden;
 t1.value = "";
 t2.display = display.visible;
 t2.value = "200.00";}
else if(event.value == "Option3"){
 t1.display = display.hidden;
 t1.value = "";
 t2.display = display.visible;
 t2.value = "350.00";}

 

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 ,
Apr 22, 2025 Apr 22, 2025

You'll find the answer here:

https://www.pdfscripting.com/public/Hiding-and-Showing-Form-Fields.cfm

 

The idea is to use a "Valiation" script on the dropdown so set the visibility

It should have the form. 

   

this.getField('Text2").value = event.value;

if(event.value == "0.00"){//Optionn 1?

   this.getField('Text1").display = display.visible;

   this.getField('Text2").display = display.hidden;

}

else if(event.value == "200.00"){//Optionn 2

   this.getField('Text1").display = display.hidden;

   this.getField('Text2").display = display.visible;

}

 

 

 

 

 

   

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Apr 22, 2025 Apr 22, 2025

Since you have export values and if you want to use validation script, then do like this:

var t1 = this.getField("Text1");
var t2 = this.getField("Text2");

if(event.value == "Option1"){
 t1.display = display.visible;
 t2.display = display.hidden;
 t2.value = "";}
else if(event.value == "Option2"){
 t1.display = display.hidden;
 t1.value = "";
 t2.display = display.visible;
 t2.value = "200.00";}
else if(event.value == "Option3"){
 t1.display = display.hidden;
 t1.value = "";
 t2.display = display.visible;
 t2.value = "350.00";}

 

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
New Here ,
May 06, 2025 May 06, 2025

Thank you so much, this worked perfectly!

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
Adobe Employee ,
May 06, 2025 May 06, 2025
LATEST

Hi @Shawna_3570,

 

Hope you are doing well.

 

Thanks for writing what worked for you, while also marking the statement as correct answer.

This would help future users with similar query use the answer as a reference.


Regards,
Souvik.

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