I have two or three forms with javascriopt that takes input values and adds them to give the total but when I tried to add this script to another form id doesn't do anything. the script is as follows:
I can't see any obvious errors in my javascript, but I may be missing something.
Any help would be welcome.
Thanks
<?php
JHtml::_('jquery.framework');
?>
jQuery(document).ready(function(jQ){
jQ('#Subs').click(calc);
jQ('#Subs1').click(calc);
jQ('#fees').click(calc);
jQ('#EfacDonation').change(calc);
jQ('#Total').click(calc);
jQ('#Donation').change(calc);
function calc() {
var don1, don2, sum1, sum2, sum3, sum4, sub, don, fees;
fees = 0;
sub = 0;
don1 = 0;
don2 = 0;
sum1 = 0;
fees = jQ('input[name=Fees]:checked').val();
if(fees === undefined){sub = 0;}
don1 = jQ('#Donation').val();
if(don1 === ''){don1 = 0;}
sub = jQ('input[name=Subs]:checked').val();
if(sub === undefined){sub = 0;}
don2 = jQ('#EfacDonation').val();
if(don2 === ''){don2 = 0;}
sum1 = parseInt(fees);
sum2 = parseInt(sub);
sum3 = parseInt(don1);
sum4 = parseInt(don2);
sum = (sum1 + sum2 + sum3 + sum4);
jQ('#total').val(sum);
}
});
I can't see any obvious errors in my javascript, but I may be missing something.
Any help would be welcome.
Thanks