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

show/hide fields based on drop down choices

Community Beginner ,
Jun 11, 2014 Jun 11, 2014

Copy link to clipboard

Copied

I have a dropdown field with three choices. Based on the selection, I need a specific text form field to appear, and the others to remain hidden. (Or if it makes the code more clean, the resulting field could be a dropdown, too, with the appropriate choice selected.) I don't know Java well enough to extrapolate code from online examples and repurpose it for my forms. I can provide a sample form. Thanks in advance for your help.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

46.5K

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

Engaged , Jun 11, 2014 Jun 11, 2014

There are some ways to execute this.  the easiest for you would be to add this script to the calculate (calculate tab in properties) event of the field that needs to be hidden.  Take notes that everything after "//" is just hints for you to understand the code.  You will need to put this script in every field that you want to replicate the behavior, changing the value according to what you want to accomplish.  the word "event" means myself for you to understand.


if (this.getField("dropdown").valu

...

Votes

Translate

Translate
New Here ,
Aug 24, 2020 Aug 24, 2020

Copy link to clipboard

Copied

Hi, Could you please show how to set filed (more than 6) set mandatory/readonly? thank you in advance, Andrey

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 ,
Aug 24, 2020 Aug 24, 2020

Copy link to clipboard

Copied

this.getField("Text1").required = true;

this.getField("Text2").readonly = true;

 

Duplicate and repeat as much as necessary.

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
New Here ,
Aug 24, 2020 Aug 24, 2020

Copy link to clipboard

Copied

thank you so much, ufortunatelly first 2 feild cnanged status, other not. 

code: custom verification/dropbox

var f1 = this.getField("phone");
var f11 = this.getField("phone_other");
var f2 = this.getField("date_order");
var f21 = this.getField("reason");
var f3 = this.getField("phone_number_other");
var f4 = this.getField("limit");
var f41 = this.getField("limit_other");
var f5 = this.getField("internet");
var f51 = this.getField("internet_other");
var f6 = this.getField("WBS");

 

if (event.value=="-Select action-") {

f1.readonly = true; f11.readonly = true;
f2.readonly = true; f21.readonly = true;
f3.readonly = true;
f4.readonly = true; f41.readonly = true;
f5.readonly = true; f51.readonly = true;
f6.readonly = true;

f1.required = false; f11.required = false;
f2.required = false; f21.required = false;
f3.required = false;
f4.required = false; f41.required = false;
f5.required = false; f51.required = false;
f6.required = false;

} else if (event.value=="Mobile phone request") {

...

}

could you please help?

BR

Andrey

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 ,
Aug 24, 2020 Aug 24, 2020

Copy link to clipboard

Copied

Check the JS Console for error messages.

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
New Here ,
Aug 24, 2020 Aug 24, 2020

Copy link to clipboard

Copied

checked, thank u so much. solve issue 

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