RadioButtonGroup value on click

Solution:

Use the onChange event for a RadioButtonGroup in order to get the current selection value in the event handler. Using onClick will return the LAST value the control had, not the current one. (There I go answering my own questions again)

Was:

I have a radiobuttongroup with 2 options, Male and Female as labels. I assigned value “f” to Female, and “m” value to Male. When the click event occurs and I fetch the .value of the object, I get the reverse expectation: ‘m’ when Female is clicked and ‘f’ when Male is clicked. I figure that the value returned is the value in the object BEFORE the click event. Easy to work around, but it’s a kludge if I have to reverse the values now so when Female is clicked I get the expected value in code, but the editor show the reverse assignments. Question: What is the best/right way to get the value of the radio button that is just clicked?

Hello Robert,

From what i understand, this snippet code will solve the problem :

export function radioGender_change(event, $w)
 {
 let radioSelectedValue = $w("#radioID").value;
    console.log(radioSelectedValue);
}

This will get you the clicked value.

Best,

Mustafa