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:
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!!!
Copy link to clipboard
Copied
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".
Copy link to clipboard
Copied
Thank you so much for your response. Some follow up questions:
1. I don't see a place to add a Calculation script to a radio group. I attach an image here of the Decline Coverage properties options. Could advise where I can find the area to add a Calculation script?
2. I've reviewed your script suggestions and updated to the best of my understanding. Is the below script now written correctly? And would the script remain [somewhere] on the Decline Coverage radio button or would it go elsewhere?
var radio2 = this.getField("Medical Waive Reason");
if (this.getField("Decline Coverage").value=="Off")
{
radio2.display = display.hidden;
radio2.value = "Off";
}
if (this.getField("Decline Coverage").value=="Med 4- waive")
{
radio2.display = display.visible;
} else {
radio2.display = display.hidden;
radio2.required = false;
radio2.value = "Off";
}
Copy link to clipboard
Copied
1. No, you won't find it. As I wrote: You can use a hidden text field for this.
2. The script is written correctly, but the logic behind it is flawed. The second part of it will completely override the first one, so you can remove that part entirely:
if (this.getField("Decline Coverage").value=="Off")
{
radio2.display = display.hidden;
radio2.value = "Off";
}
Another issue is the required property. If you want the field to be required when visible you have to set it as true. Otherwise there's no need to set it as false in your code, as it only needs to happen once.
Copy link to clipboard
Copied
Hi there,
I guess I'm confused on how to accomplish step 1. How do I use a hidden text field on a radio button? I have the Mouse Up script on the final radio button ("Decline Coverage") out of nine. It sounds like you need me to move the script but I'm not sure to where. If I need to create a new field, how would it be connected to the radio group?
Thanks for being patient with me. I am completely self-taught and this is something I haven't mastered yet.