$(document).ready(function(){ $('#handle-pax').handleCounter({ minimum: 1, maximize: 12, onChange: function(e) { qtyChanged('pax',e) } }) .click(function(e){ event.preventDefault(); }); $('#handle-room1').handleCounter({ minimum: 0, maximize: 12, onChange: function(e) { qtyChanged('room1',e) } }) .click(function(e){ event.preventDefault(); }); $('#handle-room2').handleCounter({ minimum: 0, maximize: 8, onChange: function(e) { qtyChanged('room2',e) } }) .click(function(e){ event.preventDefault(); }); $('#handle-room3').handleCounter({ minimum: 0, maximize: 5, onChange: function(e) { qtyChanged('room3',e) } }) .click(function(e){ event.preventDefault(); }); $('#handle-wstick').handleCounter({ minimum: 0, maximize: 5, onChange: function(e) { qtyChanged('wstick',e) } }) .click(function(e){ event.preventDefault(); }); $('#handle-horse').handleCounter({ minimum: 0, maximize: 5, onChange: function(e) { qtyChanged('horse',e) } }) .click(function(e){ event.preventDefault(); }); $('#check-train').click(function () { var checked = ($(this).prop('checked')) ? 1 : 0; $('#total-train').val(checked*$('#price-train').val()); Calc(); }); }); function ChangeHotel() { var hotel = $('#hotel').val(); var hprice = new Array(); hprice['RETAMA'] = new Array(4); hprice['RETAMA'][1]=0; hprice['RETAMA'][2]=0; hprice['RETAMA'][3]=0; hprice['TARA'] = new Array(4); hprice['TARA'][1]=0; hprice['TARA'][2]=0; hprice['TARA'][3]=0; hprice['INTI PUNKU'] = new Array(4); hprice['INTI PUNKU'][1]=20; hprice['INTI PUNKU'][2]=10; hprice['INTI PUNKU'][3]=20; hprice['HATUN INTI'] = new Array(4); hprice['HATUN INTI'][1]=20; hprice['HATUN INTI'][2]=10; hprice['HATUN INTI'][3]=20; for(i=1; i<4; i++) { if(hprice[hotel][i]==-1) { $('#price-room'+i).val(0); $('#total-room'+i).val(0); } else { $('#price-room'+i).val(hprice[hotel][i]); $('#total-room'+i).val($('#price-room'+i).val()*$('#spinner-room'+i).val()); } } Calc(); } function CalcProfile() { pax = parseInt($('#spinner-pax').val()); price = parseInt($('#price-sic').val()); $('#total-sic').val(pax*price); CalcTotal(); } function Calc() { var total = 0; /* var pax = parseInt($('#spinner-pax').val()); var checked = ($('#check-train').prop('checked')) ? 1 : 0; $('#total-train').val(checked * pax * $('#price-train').val()); */ $("input[id^='total-']").each(function() { total += parseInt($(this).val()); }); //$('#TOTAL').val(options + parseInt($('#total-sic').val())); $('#TOTAL').val(total); } function qtyChanged(obj,qty) { if(isNaN($('#price-'+obj).val())) return; var price = $('#price-'+obj).val(); $('#total-'+obj).val(qty*price); Calc(); }