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

Adding logic to a drop down list selection

Explorer ,
Feb 02, 2023 Feb 02, 2023

I created a complex form that already has several scripts functioning. And due to this, I have two questions:

 

  1. How do we add logic to a selection (for example, a checkbox tells user to skip to page 5 if that page is irrelevant to them). I added a link on "page 5" to take them to the page, however, that current page is open for editing still. Once the user clicks on that checkbox, can it make the rest of that page (and pages 2-4) uneditable?
  2. With all the scripts functioning at once, will this damage the file and make either one or all functions to malfunction?

 

Thank you!

TOPICS
General troubleshooting , How to , JavaScript , PDF forms , Standards and accessibility
999
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 ,
Feb 03, 2023 Feb 03, 2023
LATEST

To make fields "unavailable" to fill out, hide them. Here's an article on the topic:

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

 

In addition. when I need to make an area of a form look like it is to be left alone. I place a translucent grey rectangle annoation over the area. The rectangle properties should be set to locked and read only. The same code that hides and shows the fields, then also shows the grey rectangle when the fields are hidden, and hides it when the fields are shown. 

 

  

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

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 ,
Feb 02, 2023 Feb 02, 2023

The best way to navigate the user from one form field to another form field is to use the "field.setFocus()" function. Then, if the user starts typing, they are typing in the correct field.

 

You don't explain how clicking on a checkbox can make an entire page un-editable. But in general it is important to be careful with your scripts so they do not interfere with one another. If a form has lots of script that have the potential for erroneously triggering other scripts, then code should be added to make sure only the right scripts run at the right time. For example, blocking recursive event triggers. 

One common way forms are made troublesome, is using too many calculation scripts. Its also problematic to write scripts that change dropdown items. These types of scripts are not bad, but they do have the potential to cause trouble.  There are lots of other possible issues with a large number of complex scripts, but you'd have to analyze each script to know.   

 

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
Explorer ,
Feb 03, 2023 Feb 03, 2023

The requestor for this logic on the form explained that the users check that box, yet they still fill out that page, even though it says in the instructions to skip to page 5. She would like it blanked out so that they have no choice but to fill out page 5 only.

 

The problem is I have a few running scripts on that page already, and I am afraid I may run into these scripts interfering with each other, as you explained above.

 

Is it still possible to add this logic on the 1st page (skip other questions on page 1 and only page 5 will be editable)?

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 ,
Feb 03, 2023 Feb 03, 2023
LATEST

To make fields "unavailable" to fill out, hide them. Here's an article on the topic:

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

 

In addition. when I need to make an area of a form look like it is to be left alone. I place a translucent grey rectangle annoation over the area. The rectangle properties should be set to locked and read only. The same code that hides and shows the fields, then also shows the grey rectangle when the fields are hidden, and hides it when the fields are shown. 

 

  

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