Reset radio group to hidden when form is cleared
I have reached my wits end trying to figure something out unsuccessfully and so I am writing here for the first time ever, hoping the commuty can assist.
I've created a benefits enrollment form that has two sets of radio button groups that are connected, "Medical" and "Medical Waive Reason" with the latter having an initial display value of hidden.
What I need to happen:
- If an employee chooses to waive coverage in the medical plan thus selects the "Decline Coverage" radio button, the "Medical Waive Reason" radio buttons become visible.
- If an employee chooses to enroll in the medical plan and selects one of the other "Medical" group radio options (not "Decline"), then the "Medical Waive Reason" radio buttons return to hidden and, if any button was selected, values cleared.
- If the entire form is cleared, therefore the "Decline Coverage" radio box is cleared, then the "Medical Waive Reason" radio buttons return to initial state of hidden, values cleared if any.
What I've accomplished:
I've managed to successfully solve for items 1 & 2. On the "Decline Coverage" radio button > Action Tab > Run a JavaScript on mouse up, I used the following script that works:
var radio2 = this.getField("Medical Waive Reason");
if (event.target.value=="Off")
{
radio2.display = display.hidden;
radio2.value = "";
}
if (event.target.value=="Med 4- waive")
{
radio2.display = display.visible;
} else {
radio2.display = display.hidden;
radio2.required = false;
radio2.value = "";
}
Where I need help:
I cannot figure out the JavaScript for how to return the "Medical Waive Reason" radio group back to the initial Hidden state when "Decline Coverage" is CLEARED. Can you help solve this mystery??? Please!!!
