As far as I understand, on "Submit Button" click, you need to loop through all the
RadioButtons
and check which ones are checked.
Solution
- Give a name to the
form
like below.
<form name="form1" target="sendinfo" id="infoform" onsubmit="return handleClick()"></form>
- Get all the
input
Elements of form like below.
var inputs = form1.elements;
- Find only the
RadioButtons
from those Elements.
var radios = [];
for (var i = 0; i < inputs.length; ++i) {
if (inputs[i].type == 'radio') {
radios.push(inputs[i]);
}
}
- Do whatever you want using
radios
.
Demo
[Demo] Get all RadioButtons inside the form[
^]
Note
In the Demo, I have commented out the codes you used to break the on getting one Radio value just to show alert for every checked Radio value. You can use that as per your logic and requirements.