Count total radio select value
by Susan Adhikary
HTML
ex<input type="radio" value="10" name="rating" />
good<input type="radio" value="6.5" name="rating" />
poor<input type="radio" value="4.5" name="rating" />
----------------------------------------------------------
<p>
ex<input type="radio" value="10" name="rating1" />
good<input type="radio" value="6.5" name="rating1" />
poor<input type="radio" value="4.5" name="rating1" />
</p>
<p>
ex<input type="radio" value="10" name="rating2" />
good<input type="radio" value="6.5" name="rating2" />
poor<input type="radio" value="4.5" name="rating2" />
</p>
<p>
The Total Sccore is <span id="total"></span>
</p>
JavaScript
function calculate() {
var count = 0;
$("input[type*=radio]:checked").each(function(){
count+=parseFloat($(this).val());
});
$('#total').html(count);
}
$().ready(function(){
$("input[type*=radio]").change(function(){
calculate()
});
});