hi teams, i trying to sum value from selected radio button, but it not working, can you help me out ? any help is appreciated
<!DOCTYPE html>
<html>
<body>
<h1>Display Radio Buttons</h1>
<form action="/action_page.php">
<br>
<label class="radio-inline">
<input class="r1" type="radio" name="a1" value="10">Option 1
</label>
<label class="radio-inline">
<input class="r1" type="radio" name="a1" value="10">Option 2
</label>
<label class="radio-inline">
<input class="r1" type="radio" name="a1" value="10">Option 3
</label>
<br>
<label class="radio-inline">
<input class="r1" type="radio" name="a2" value="10">Option 1
</label>
<label class="radio-inline">
<input class="r1" type="radio" name="a2" value="10">Option 2
</label>
<label class="radio-inline">
<input class="r1" type="radio" name="a2" value="10">Option 3
</label>
<br>
<label class="radio-inline">
<input class="r1" type="radio" name="a3" value="10">Option 1
</label>
<label class="radio-inline">
<input class="r1" type="radio" name="a3" value="10">Option 2
</label>
<label class="radio-inline">
<input class="r1" type="radio" name="a3" value="10">Option 3
</label>
<br>
<button type="button" onclick="displayRadioValue()">
Submit
</button>
<div id="result"></div>
</form>
</div>
<script>
function displayRadioValue(){
var score = 0;
var ele = document.getElementsByName('r1');
for(i = 0; i < ele.length; i++) {
if(ele[i].checked)
document.getElementById("result").innerHTML
score+=parseInt(ele[i].value)
}
}
</script>
</body>
</html>