• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

Reset radio group to hidden when form is cleared

New Here ,
May 10, 2024 May 10, 2024

Copy link to clipboard

Copied

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:

  1. 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.
  2. 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.
  3. 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!!!

TOPICS
PDF forms

Views

67

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 10, 2024 May 10, 2024

Copy link to clipboard

Copied

LATEST

Use a Calculation script to do this, instead of a Mouse Up one. The former is triggered when the form is cleared, the latter isn't. You can use a hidden text field for this. The only thing you need to adjust in your code, basically, is to replace event.target.value with this.getField("Decline Coverage").value.

However, there's an error in your code. If "Medical Waive Reason" is a radio-button group then setting its value to "" will not clear it. You need to set it to "Off".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines