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

Hiding Text fields and check boxes depending on user input

Explorer ,
Jan 15, 2024 Jan 15, 2024

Hi,

 

I have a form that requires some text fields and check boxes to be hidden if a serial number that is inputted by the user contains certain numbers/ letters for example:

 

I would like all text fields to be shown if the initial box is empty/ if the form is cleared however, if the user inputs a serial number such as ABCD22440ABD12345 i would like the following boxes hidden: "Stuffer Box", "Waffle Plates", "Check Box13.7" and "Check Box14.5".

 

if ther serial number does not contain 2244 i would like "Packer Guard" and "Check Box13.3" to be hidden

 

if i can get that working i can probably get everything else i require to work.

 

Thank you

TOPICS
Acrobat SDK and JavaScript
190
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 ,
Jan 15, 2024 Jan 15, 2024
LATEST

Here's an article on exactly this topic:

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

https://www.pdfscripting.com/public/How-to-write-an-If-statement.cfm

 

To find specific text in a string, use the "indexOf()" function.  

Here's some example code. It's not complete for the conditions you've mentioned. 

 

if(this.getField("serial").valueAsString.indexOf("2244") > -1)

{

    ... Hide/Show fields associated with this codition...

}

else

{

    ... Hide/Show fields associated with this codition...

}

 

 

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