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

Using custom validation scripts to change visibility of other form elements

New Here ,
Apr 21, 2023 Apr 21, 2023

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;

TOPICS
How to , JavaScript
1.8K
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 ,
Apr 21, 2023 Apr 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 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
New Here ,
Apr 21, 2023 Apr 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 : .....

 

 

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
New Here ,
Apr 21, 2023 Apr 21, 2023

I get this error

 

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

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 ,
Apr 21, 2023 Apr 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 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
New Here ,
Apr 25, 2023 Apr 25, 2023

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

 

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 ,
Apr 25, 2023 Apr 25, 2023
LATEST

Delayed execution on a field change is usually one of two things.

1. "Commit immediately on selection" is not checked

2. Calculation Ordering is off (for caculation scripts only)

 

Doesn't seem like either of these two is your problem. 

At this point you'll need to debug by inserting "console.println" statements into the code to track progress. 

 

 

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