Copy link to clipboard
Copied
I'm currently creating a form where many of the questions are conditional and I have never worked with JavaScript before.
For example, Q9 requires the user filling out the form to select radio buttons in Group "Q9" as "Yes" or "No". Based on their selection, a text box, another Yes/No set of radio buttons, or a list box will become required and change from "readonly=true" to "readonly=false".
Another example, I'd like help with is for list box conditions. For example, Q9 has a list box appear after the Yes/No radio button has been selected, but the listbox has a second condition, the list box is multiple choice and if "Other" is chosen, a text box will become required and change from "readonly=true" to "readonly=false" as well to explain what "Other" is.
Any help would be GREATLY appreciated!
Copy link to clipboard
Copied
You need to create a pair of radio buttons with the same name and a different export value for each.
In my example code below, I am using "select" as the radio buttons fieldname.
One radio button will have "Choice1" as the export value and the other one "Choice2".
Use this code as a mouse-up action javascript for the radio button with export value "Choice1":
this.getField("myListBox").display = display.visible;
And do the same for the other radio button with export value of "Choice2 using this other line:
this.getField("myListBox").display = display.hidden;
Then add the following line of code to your list box as a mouse-up javascript action:
if (event.target.value =="Other") {
this.getField("myTextField").display = display.visible
} else {
this.getField(myTextField").display = display.hidden;
}