Copy link to clipboard
Copied
I'm using the document level function to automatically check boxes yes when a form field is populated. However, there are 4 different checkboxes that need their own if statement. How do I join multiple if statements in one function? I'm not a javascript coder so I don't know. Thanks in advance!
This is what I have:
function Checkboxes789()
{if (this.getField("contract fee").valueAsString!="")
{this.getField("Q7N").value = "yes";}
else
{this.getField("Q7N").value = "no";}
if (this.getField("Waived Txt").valueAsString!="")
{this.getField("7AN").value = "yes";}
else
{this.getField("7AN").value = "no";}
if (this.getField("lb_name").valueAsString!="")
{this.getField("Q8N").value = "yes";}
else
{this.getField("Q8N").value = "no";}
if (this.getField("DBNames").valueAsString!="")
{this.getField("DB9N").value = "yes";}
else
{this.getField("DB9N").value = "no";}
}
Copy link to clipboard
Copied
That should work, though you're missing a final curly brace. Also, those if statements can be simplified like:
getField("Q7N").value = getField("contract fee").valueAsString ? "Yes" : "No";
Copy link to clipboard
Copied
Sorry, ignore that part about the missing curly brace - I see it now.
Copy link to clipboard
Copied
Thanks, but the multiple statements I have above do not work when combined together. Am I missing something?
Copy link to clipboard
Copied
Check to see if any errors are reported in the JavaScript console (Ctrl+J). If there are none, you'll have to provide more information. Note that for a check box, the value of the field when checked is whatever you set the export value to (often "Yes", but not "yes"), and will be "Off" (but not "off", "no", or anything else) when unchecked. So you'll have to adjust your code to account for this.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more