Copy link to clipboard
Copied
Hi,
How can I make a text field visible based on a check box selection ? I tried the following:
if (this.getField("MyCheckBox").isBoxChecked(0))
{this.getField("TextFormFieldToBeDisplayed").display = display.visible;}
else
{this.getField("TextFormFieldToBeDisplayed").display = display.hidden;}
But my check box is apart of a series .. I have 2 check boxes all called "template"
and their export values are individual, and multiple.
I am trying to make 1 text box visible and another one hidden if individual is selected, then reversed if multiple is selected.
Thank you!
Use a separate (hidden) text field with the following code as the custom calculation script:
var v = this.getField("MyCheckBox").valueAsString;
if (v=="Off" || v=="individual") {
this.getField("Field1").display = display.visible;
this.getField("Field2").display = display.hidden;
} else {
this.getField("Field1").display = display.hidden;
this.getField("Field2").display = display.visible;
}
Change the field names as needed, of course.
Copy link to clipboard
Copied
What about if neither one is selected? Also, where did you place this code?
Copy link to clipboard
Copied
One always has to be selected for the siuation. Either one or the other is hidden. The question on the form is mandatory.
Copy link to clipboard
Copied
That doesn't mean it will always be the case. The user will be able to un-select both fields, and the script has to take that into consideration or you will get strange and probably unwanted results.
Copy link to clipboard
Copied
If neither is selected then I would like the text box realted in "individual" to be visible and "multiple" hidden.
I pasted this code into the custom calculate of the text boxes.
Copy link to clipboard
Copied
Use a separate (hidden) text field with the following code as the custom calculation script:
var v = this.getField("MyCheckBox").valueAsString;
if (v=="Off" || v=="individual") {
this.getField("Field1").display = display.visible;
this.getField("Field2").display = display.hidden;
} else {
this.getField("Field1").display = display.hidden;
this.getField("Field2").display = display.visible;
}
Change the field names as needed, of course.
Copy link to clipboard
Copied
Thank you!
I have a dumb question .... how can I learn all of this?
Should I take coding classes or is there a better way to learn javascript for Adobe.
Copy link to clipboard
Copied
It's a pretty niche market, so there's not a huge amount of resources out there. It would be good to know some general coding practices and concepts, sure. On top of that you could use these resources:
General JS tutorial (note that only the core syntax applies to Acrobat): http://www.w3schools.com/js/default.asp
Homepage for Acrobat JavaScript development, including a link to the full API: http://www.adobe.com/devnet/acrobat.html
Free tutorials about Acrobat in general, including many JS related ones: https://acrobatusers.com/tutorials/
A paid-for website with tutorials about Acrobat JavaScript (not related to me): http://www.pdfscripting.com/
My humble web-site with many tools for Acrobat (mostly paid-for, some free): http://try67.blogspot.com
Copy link to clipboard
Copied
Thank you for all your help !