Skip to main content
Known Participant
April 21, 2023
Question

Using custom validation scripts to change visibility of other form elements

  • April 21, 2023
  • 2 replies
  • 1833 views

I have hit a block!..All I wish for is: if "User" is selected in Dropdown15a, "Dropdown15b" and "Exposurevolumequantity" are hidden and any values (Exposurevolumequantity) or previous selections (Dropdown15b) expunged!

 

The script is placed within the custom validation script of "Dropdown15a"

Dropdown15a has four options and I Have assigned Export values to the dropdown choices identified in the ()

" " (0), "Delivered form"(0), "Pre-measured"(0), "User"(1). 

The " " is the initial drop down state i.e. empty(ish)

Other than 'Check spelling' no other option radios are selected. 

 

this.getField("Dropdown15b").display = (this.getfield("Dropdown15a").valueAsString == "User") ? display.hidden : display.visible;
this.getField("Exposurevolumequantity").display = (this.getfield("Dropdown15a").valueAsString == "User") ? display.hidden : display.visible;

This topic has been closed for replies.

2 replies

Known Participant
April 21, 2023

Hi Thom, 

 

Although the export values are assinged I am not actually 'calling' them in the script. What I can't understand is why the the scripts are not working using the valueAsString. All I want is to identify the "User" selection from the dropdown list. But if there is a code modification that would work with the export values rather than strings I am happy to assign unique identifiers 1 through to 4 and implement. Assuming the export value for "User" = 4 then I presume I would change the script to ......15a").value = 4 ? display.hidden : .....

 

 

Known Participant
April 21, 2023

I get this error

 

TypeError: this.getfield is not a function
1:Field:Validate

Thom Parker
Community Expert
Community Expert
April 21, 2023

I think you've got it.  The value of a dropdown or list field is the export value. Don't include the export, and the field value will be the display text.  So you can go either way. Change the code to use the export, or remove the exports. 

 

And you definately need to fix the error.  JavaScript is case sensitive, so the name of the function is "getField" with a capital "F". 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
April 21, 2023

So what exactly is not working?

 

One possible problem is that the export values need to be unique, because it is the export value that uniquely identifies the list item.  

 

 

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