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

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

Explorer ,
Nov 16, 2017 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

1.1K

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 ,
Nov 16, 2017 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

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

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
Explorer ,
Nov 16, 2017 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.

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 ,
Dec 01, 2017 Dec 01, 2017

Copy link to clipboard

Copied

LATEST

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

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

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

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