Radio buttons to show element

Hi all, I am trying to do a questionnaire on my website but i can’t seem to show the specific questions based on what the clients answers. I tried to use either the button or the radio button onClick functions or onChange functions but both doesn’t work either.

Was wondering whether my code is wrong. I have checked the forum and used the code that is supposed to be working ( https://www.wix.com/corvid/forum/community-discussion/radio-buttons-value-to-show-and-hide-an-element-solved ) but it is not working for me. the console log is working but the boxes does not show.
the code is below:
export function buttonQ1_click(event) {
if ($w(“#radioGroupQ1”).value === “Radio button1”) {
$w(“#boxinjury”).collapse();
$w(“#box24”).expand();
}
if ($w(“#radioGroupQ1”).value === “Radio button2”) {
$w(“#boxinjury”).expand();
}
if ($w(“#radioGroupQ1”).value === “Radio button3”) {
$w(“#boxinjury”).expand();
}
if ($w(“#radioGroupQ1”).value === “Radio button4”) {
$w(“#boxinjury”).expand();
}
console.log(“box2 expanded”)
}

Thank you!!

The code looks fine so the problem is somewhere else. Maybe you made them hidden instead of collapsed so expand() won’t help here.
Also try:

console.log($w("#radioGroupQ1").value);

and see what you get.

Thanks J.D. it is great to hear that the code looks fine…

I’ve checked the box, it was originally collapsed. (see below)

I thought it was because this box was in another box but after changing that I still have the same problem.

The log that I got corresponds to the value of the radio button that was clicked.

are there anything else I can check?


Thanks

I really don’t know. Your code looks fine.

@jonatandor35 Thanks anyways… :slight_smile: