ListBox item selection to show/hide (several) other form fields

Community Beginner ,
Nov 16, 2017

Copy link to clipboard

Copied

Salut!

I am preparing a form in Acrobat. I have a listbox (e.g., ListBox1) with 10 items (e.g., item1, item2, item3). I would like to show/hide other form fields (that I already created) dynamically according to users selection from the listbox.

For example, if user selects "item1" from ListBox1, I will display only form field#1 or if user selects item2 from ListBox1, I will display only form field#2, and so on...

 

I will be really looking forward for any suggestions/corrections.

------

PS. I used the following amongst others for my ListBox1:

if(event.value !="item1") {

this.getField("field1").display = display.visible;

this.getField("field2").display = display.hidden;

}

else if (event.value !="item2")

{

this.getField("field1").display = display.hidden;

this.getField("field2").display = display.visible;

}

else if.....

TOPICS
Acrobat SDK and JavaScript, Windows

Views

425

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

ListBox item selection to show/hide (several) other form fields

Community Beginner ,
Nov 16, 2017

Copy link to clipboard

Copied

Salut!

I am preparing a form in Acrobat. I have a listbox (e.g., ListBox1) with 10 items (e.g., item1, item2, item3). I would like to show/hide other form fields (that I already created) dynamically according to users selection from the listbox.

For example, if user selects "item1" from ListBox1, I will display only form field#1 or if user selects item2 from ListBox1, I will display only form field#2, and so on...

 

I will be really looking forward for any suggestions/corrections.

------

PS. I used the following amongst others for my ListBox1:

if(event.value !="item1") {

this.getField("field1").display = display.visible;

this.getField("field2").display = display.hidden;

}

else if (event.value !="item2")

{

this.getField("field1").display = display.hidden;

this.getField("field2").display = display.visible;

}

else if.....

TOPICS
Acrobat SDK and JavaScript, Windows

Views

426

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
Nov 16, 2017 0
Adobe Community Professional ,
Nov 16, 2017

Copy link to clipboard

Copied

In which event did you put this script?

The best way to setup a list is to set the "Commit immediate" option and then use the "Custom"  Keystroke Event Script on the "Format" tab.

Start you script like this

if(event.willCommit)

{

  ... your existing code ...

}

Use the console to display key values you need to determine whether or not the script is working.

Here is an article and a video you'll find useful

https://acrobatusers.com/tutorials/js_list_combo_livecycle

https://www.pdfscripting.com/public/images/Free_Videos/BeginJS_Console_Alt_mp4.cfm

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
Reply
Loading...
Nov 16, 2017 1
Community Beginner ,
Nov 16, 2017

Copy link to clipboard

Copied

Thank you @Thom for advices. I will check them, and write my experience accordingly.

One simple issue: I put the script in MouseUp event. After reading your comment I see it's a problem.

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
Reply
Loading...
Nov 16, 2017 0
Adobe Community Professional ,
Dec 01, 2017

Copy link to clipboard

Copied

Here's another article that will be helpful in list programming.

https://www.pdfscripting.com/public/List-Field-Usage-and-Handling.cfm

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
Reply
Loading...
Dec 01, 2017 1