Copy link to clipboard
Copied
I have the following form and code working as I would like but would like to know how to improve the code for a more involved form. The code checks to see that the radio buttons have a selection and then unhides the signature block and hides the signature button for the respective column. The more involved form will have 4 columns and at least 10 radio buttons for each column. The listed code is set to a Mouse Enter trigger of the Engineering Signoff button.
var EN1 = this.getField("EN1").value;
var EN2 = this.getField("EN2").value;
var EN3 = this.getField("EN3").value;
if ((EN1=="Off") || (EN2=="Off") || (EN3=="Off")) {
this.getField("ENSig").display = display.hidden
this.getField("ENChk").display = display.visible
}
else {
this.getField("ENSig").display = display.visible
this.getField("ENChk").display = display.hidden
}
Wouldn't you want the signature blocks hidden until all selections have been made instead of triggering the visibility with a Mouse Enter action? In my opinion, if the user puts the mouse over the field and it disappears it will seem like there is something wrong with the form. Back to your question, if you continue with the radio button naming convention, you could run a loop to set the visibility like this:
this.getField("ENSign").display = display.visible;
this.getField("ENChk").display = di
Copy link to clipboard
Copied
Wouldn't you want the signature blocks hidden until all selections have been made instead of triggering the visibility with a Mouse Enter action? In my opinion, if the user puts the mouse over the field and it disappears it will seem like there is something wrong with the form. Back to your question, if you continue with the radio button naming convention, you could run a loop to set the visibility like this:
this.getField("ENSign").display = display.visible;
this.getField("ENChk").display = display.hidden;
for(var i=1;i < 11; i++)
{
if(this.getField("EN"+i).value=="Off")
{
this.getField("ENSign").display = display.hidden;
this.getField("ENChk").display = display.visible;
break;
}
}
Copy link to clipboard
Copied
Sorry, the screenshot above is in Prepare Form mode. The signature block is hidden when the form is open.
At first your code didn't work and I thought I was doing something wrong, but then I realized you had "ENSign" instead of "ENSig" 🙂 I fixed that and it is working as intended, thank you.
Copy link to clipboard
Copied
🙂