Unable to refresh value of radio button

Hello,
I have a radio button with 3 choices.
Depending to the choice I want to hide (or not) texts and input texts fields.
Unfortunately, when I select values the radio button, there is no any action
The .value of the radio button is not refreshed.
Can you please advise?
Regards,
Pierre-yves

if ($w(“#bookingRadioGroup”).value === “Radio Button1”) {
$w(“#text25”).hide();
} else {
if ($w(“#bookingRadioGroup”).value === “Radio Button2”) {
$w(“#text34”).hide();
} else {
if ($w(“#bookingRadioGroup”).value === “Radio Button3”) {
$w(“#text34”).hide();
}

	} 
}

Hi Pierre-yves,

I suspect that you are not getting the correct radio button selection. Use the following code as a guide on how to get the selected radio button:

export function radioGroup1_change(event, $w) {
	let sel = $w("#radioGroup1").selectedIndex;
	console.log("change " + sel);
}

The $w.RadioButtonGroup.onChange() event will trigger when the selection changes. You can add the logic to do whatever you want based on that selection. The console.log will show you which radio button was selected in the developers console. This helps you see how your code works.

Refer to the $w.RadioButtonGroup API for more details on how to use the radio buttons.

Good luck,

Yisrael

Dear Yisrael,

You completely right, I did not select the correct trigger…
It works now !
Thanks for your help (again :wink: )
pym

Hi I have tried to insert only two option for the radio button to visualize some drop down input box but I cannot see them anyway. What Do I do wrong?

export function radioGroup1_change(event, $w) {

if ($w(“#radioGroup1”).value === “Radio Button1”) {
$w(“#dropdown1”).show();
$w(“#dropdown2”).show();

} else {
($w(“#radioGroup1”).value === “Radio Button2”)
$w(“#dropdown1”).hide();
$w(“#dropdown2”).hide(); }
}

Actually I have just realized, once the dropdown appear they cannot hide anymore. Do I need to reset something to make them to go away when I select Radio Button2? I see as well the contents inside the dropdown will not show even if they are programmed correctly and they work well without the radio button do I need to preload them when I click on the radio button? how do I do that?