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