$(document).ready(function(){ $('#handle-pax1').handleCounter({ minimum: 0, maximize: 16, onChange: function(e) { qtyChanged('pax1',e) } }) .click(function(e){ event.preventDefault(); }); $('#handle-pax2').handleCounter({ minimum: 0, maximize: 16, onChange: function(e) { qtyChanged('pax2',e) } }) .click(function(e){ event.preventDefault(); }); $('#handle-pax3').handleCounter({ minimum: 0, maximize: 16, onChange: function(e) { qtyChanged('pax3',e) } }) .click(function(e){ event.preventDefault(); }); $('#handle-port').handleCounter({ minimum: 0, maximize: 16, onChange: function(e) { qtyChanged('port',e) } }) .click(function(e){ event.preventDefault(); }); $('#handle-bag').handleCounter({ minimum: 0, maximize: 16, onChange: function(e) { qtyChanged('bag',e) } }) .click(function(e){ event.preventDefault(); }); $('#handle-wstick').handleCounter({ minimum: 0, maximize: 16, onChange: function(e) { qtyChanged('wstick',e) } }) .click(function(e){ event.preventDefault(); }); $('#handle-room1').handleCounter({ minimum: 0, maximize: 16, onChange: function(e) { qtyChanged('room1',e) } }) .click(function(e){ event.preventDefault(); }); $('#handle-room2').handleCounter({ minimum: 0, maximize: 16, onChange: function(e) { qtyChanged('room2',e) } }) .click(function(e){ event.preventDefault(); }); $('#handle-room3').handleCounter({ minimum: 0, maximize: 16, onChange: function(e) { qtyChanged('room3',e) } }) .click(function(e){ event.preventDefault(); }); $('#check-vistadome').click(function () { Calc(); }); $('#check-guide').click(function () { var checked = ($(this).prop('checked')) ? 1 : 0; $('#total-guide').val(checked*$('#price-guide').val()); Calc(); }); $('#check-camp').click(function () { if($(this).prop('checked')==1) { $('#select-hotel').val(0); $('#select-hotel').trigger("change"); } Calc(); }); $('#select-hotel').change(function () { var hotel = $(this).val(); if(hotel==0) { for(i=1; i<4; i++) { $('#price-room'+i).val(0); $('#total-room'+i).val(0); } } else { $('input[name=check-camp]').prop('checked', false); var hprice = new Array(); hprice['RETAMA'] = new Array(4); hprice['RETAMA'][1]=60; hprice['RETAMA'][2]=70; hprice['RETAMA'][3]=90; hprice['TARA'] = new Array(4); hprice['TARA'][1]=80; hprice['TARA'][2]=90; hprice['TARA'][3]=110; hprice['INTI PUNKU'] = new Array(4); hprice['INTI PUNKU'][1]=100; hprice['INTI PUNKU'][2]=100; hprice['INTI PUNKU'][3]=130; hprice['HATUN INTI'] = new Array(4); hprice['HATUN INTI'][1]=100; hprice['HATUN INTI'][2]=100; hprice['HATUN INTI'][3]=130; for(i=1; i<4; i++) { $('#price-room'+i).val(hprice[hotel][i]); $('#total-room'+i).val($('#price-room'+i).val()*$('#spinner-room'+i).val()); } } Calc(); }); }); function vcheck(obj) { var qty = (document.getElementById(obj).checked) ? 1 : 0; $('#'+obj+'total').html(qty * $('#'+obj+'price').html()); Calc() } function Calc() { var total = 0; var pax = parseInt($('#spinner-pax1').val()) + parseInt($('#spinner-pax2').val()) + parseInt($('#spinner-pax3').val()); var checked = ($('#check-vistadome').prop('checked')) ? 1 : 0; $('#total-train').val(checked * pax * $('#price-train').val()); var checked = ($('#check-camp').prop('checked')) ? 1 : 0; $('#price-camp').val((pax==1) ? 39 : 19); $('#total-camp').val(checked * pax * $('#price-camp').val()); $("input[id^='total-']").each(function() { total += parseInt($(this).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(); }