Copy link to clipboard
Copied
if (event.target.value == "Off") //Checkbox "I will not be using air travel"
{
this.getField("air-noptoTravelOut:date").readonly=false
this.getField("air-noptoTravelReturn:date").readonly=false
this.getField("nopto-airfareCost").readonly=false
this.getField("attach-flightNopto").readonly=false
this.getField("air-ptoTravelOut:date").readonly=false
this.getField("air-ptoTravelReturn:date").readonly=false
this.getField("pto-airfareCost").readonly=false
this.getField("attach-flighPto").readonly=false
}
else
{
this.getField("air-noptoTravelOut:date").readonly = true;
this.getField("air-noptoTravelReturn:date").readonly=true;
this.getField("nopto-airfareCost").readonly=true;
this.getField("attach-flightNopto").readonly=true;
this.getField("air-ptoTravelOut:date").readonly=true;
this.getField("air-ptoTravelReturn:date").readonly=true;
this.getField("pto-airfareCost").readonly=true;
this.getField("attach-flightPto").readonly=true;
}
I am designing a form where the are multiple sections. In one section, there is a checkbox the user can check off to indicate that the section its associated with does not apply to them. I have added MouseUp JavaScript (with the help of this forum) to disable all 9 fields associated with that section when the user checks the box. The defaut unchecked.
The problem comes when the user opens the form. Upon launch, regardless of the default application to hand the PDF, the frist of the nine fields is disabled. The only way I have found to enable that field is to check the box, then uncheck it. My thought is to add JavaScript to check the box, then uncheck it immediately upon opening it, but that feels like a bad way to handle it.
Any ideas on how to deal with this, and if the solution I just proposed is the way to do it, how to apply JS to run at launch?
i have provided the only JS code I have in the document at this point.
All you have to do is add your script as a document level script. It will run every time the document opens. However, you must change event.target to this.getField("field name"). This article explains how to enter a document level script:
https://pdfautomationstation.substack.com/p/document-level-scripts
Copy link to clipboard
Copied
All you have to do is add your script as a document level script. It will run every time the document opens. However, you must change event.target to this.getField("field name"). This article explains how to enter a document level script:
https://pdfautomationstation.substack.com/p/document-level-scripts
Copy link to clipboard
Copied
Thank you. Unfortunately, this is how I had to handle this, but creating a document level script to check and then uncheck the fields. The linked article is a bit dated and is unclear on exactly how to get to the document-level Javascript console. For the lates version of Acrobat as of this writing, you need to go to the All Tools menu and select Prepare a form. Then click the 3 dots to the right of "Prepare a form" and select Document javascript.
Copy link to clipboard
Copied
When you select 'Prepare form' tool, you can use a shortcut to open document JavaScript SHIFT+D.
Copy link to clipboard
Copied
You have an error in last field name, missing letter t:
"attach-flighPto"
"attach-flightPto"