Get Radio Button Value in JavaScript
<script>
function getvalue() {
var radios = document.getElementsByName("test");
for (var i = 0; i < radios.length; i++) {
if (radios[i].checked) {
alert(radios[i].value);
break;
}
}
}
</script>
<input type="radio" name="test" value="first" onclick="getvalue();">
<input type="radio" name="test" value="second" onclick="getvalue();">
<script>
function getvalue() {
var radios = document.getElementsByName("test");
for (var i = 0; i < radios.length; i++) {
if (radios[i].checked) {
alert(radios[i].value);
break;
}
}
}
</script>
<input type="radio" name="test" value="first" onclick="getvalue();">
<input type="radio" name="test" value="second" onclick="getvalue();">
No comments:
Post a Comment