I am having a list of questions and for each question having 4 options. Now I want to know, which radio button is checked ?
If the radio buttons have ids you could use:
if (document.getElementById('radioId').checked){
//do something
}
If you have loads of them you could use:
var radioButtons = document.getElementsByName('radioButtonName');
To get all the radio buttons that have that name field and then loop through them all with a for loop with an if statement to see if they are checked inside.
for(i=0;i<radioButtons.length;i++){
if(radiobutton[i].checked){
//do something
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments