calculate form fields using jquery-Collection of common programming errors
You can bind a change()
to both the :radio
and elements to calculate the total.
$("select[name='number'], :radio[name='type']").change(function(){
var $r = $(":radio[name='type']:checked");
var $d = $("select[name='number']");
if($r.length ==1){
var t = parseInt($r.val(), 10);
var n = parseInt($d.val(), 10);
$("#result").val(t*n);
}
});
Example on jsfiddle