I have an array of Radio Buttons right now I am performing a function separately for each set of radio button but I know that I can just use a forEach loop. I'm having trouble writing the code. Any advice is appreciated. Or maybe I could a onChange button for the array.
My code is below.
let pointAdden = [$w('#radioGroup1'), $w('#radioGroup2'), $w('#radioGroup3'),$w('#radioGroup4')]
export function radioGroup1_change(event) {
//When radiogroup1 is changed then the daily total is changed.
$w('#input2').value = Number ($w('#radioGroup1').value) +
Number ($w('#radioGroup2').value) +
Number ($w('#radioGroup3').value) +
Number ($w('#radioGroup4').value);
}
export function radioGroup2_change(event) {
$w('#input2').value = Number ($w('#radioGroup1').value) +
Number ($w('#radioGroup2').value) +
Number ($w('#radioGroup3').value) +
Number ($w('#radioGroup4').value);
}
export function radioGroup3_change(event) {
$w('#input2').value = Number ($w('#radioGroup1').value) +
Number ($w('#radioGroup2').value) +
Number ($w('#radioGroup3').value) +
Number ($w('#radioGroup4').value);
//Add your code for this event here:
}
export function radioGroup4_change(event) {
$w('#input2').value = Number ($w('#radioGroup1').value) +
Number ($w('#radioGroup2').value) +
Number ($w('#radioGroup3').value) +
Number ($w('#radioGroup4').value);
//Add your code for this event here:
}
How set select all option with checkbox in wix velo code
I'm a teacher and the website tracks student behavior points in each class. Each set of radio button is a category for the point and whenever the value of the set changes I need the Daily Point Total to change. Right now I have a onChange function for each set of radio button but I would like to make an array of the radio buttons and then run a forEach loop
Hi,
What exactly are you trying to achieve? is the code not working? or you want to use the forEach() for readability and visibility?