What would be the best way to put all the checkboxes in a single event?
Example is the code below, and I have 20 of it (from #tcbx1- #tcbx20).
function tblcheckboxes(){
var a=0;
if ($('#tcbx1').is(":checked")) {
a = parseFloat($("#tcbx1").val(), 10);
}
$(document).ready(function(){
$('#tcbx1').click(function(){
tblcheckboxes();
grandtotal();
});
});
And another checkbox that has a different id and different $(document).ready(function(){ (from #cbx3- #cbx5)
function grandtotal(){
var g=0;
if ($('#cbx3').is(":checked")) {
g = parseFloat($("#cbx3").val(), 10);
}
$(document).ready(function(){
$('#cbx3').click(function(){
grandtotal();
});
The first checkbox is grouped in a single table and the other checkbox are just some add-ons.
Aucun commentaire:
Enregistrer un commentaire