Copy link to clipboard
Copied
Hello, I am VERY new to Javascript and have been scouring these threads to find a solution, but I'd appreciate any assistance! I'm trying to develop a conditional form with 8 checkboxes. If a checkbox is selected, I want the applicable text to appear. I was able to make this work using the Actions Tab and "Show/hide a field."
However, if the checkbox is unchecked, I'd like the text to be hidden. I drafted the code for a text field, but that didn't seem to work:
if (event.target.value("CHECKBOX").value=="Off")
event.target.value("TEXTFIELD").value="";
Also are there any suggestions as to how to adjust the formatting if only 4 of 8 checkboxes are applied? I tried to input the terms into a table, but I'm not sure how that would work...
Copy link to clipboard
Copied
event.target.value is not a function. You can't use a parameter at this.
Copy link to clipboard
Copied
event.target is used if your script is executed directly from the target field; in this case, for example, a checkbox field.
You may modify the script like this:
/*
first declare your variables, as a good rule of thumb always place your declarations at the very top of your script(s)
*/
var f = event.target;
var field = this.getField("TEXTFIELD");
// then establish your IF condition(s)
if (f.value == "Off") {
text.value = "";
}
As to how to achieve this when at least four out of the eight checkboxes are checked, a more elaborate JavaScript script is needed; it is not that trivial if you're new to Acrobat JavaScript.