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

Known Participant
April 25, 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,

Thank you. 

I have revisited my code!

 

The strangest thing happens. I can use the dropdown to select any of the first three options (i.e. not User) and nothing happens.

However, as soon as I select the one of the same three options imeadiately after selecting "User" (Nothing happens imeadiately after selecting it) the two cells "Dropdown15b" and " ExposureVolumeQuantity" dissapear. Only to reapear on the next selection which can be any of the four options including "User". This is a consistent trait. the code only operates on the selction after the "User" option has been selected..Is there a logical reason? Happy to attach the form if it will help and there is a method to do so.

 

I have removed the export values from all four drop down options. Have selected "imeadiately commit values" and returned the code to .................this.getField("Dropdown15a").value == "User") ? display..........

All the "this.getFields" checked/corrected for case sensitive errors. 

 

Kind regards

 

Rob

 

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