我有这个脚本:
$(window).load(function(){
$('.math1').on('change', function(e) {
updateSubtotal();
updateDifferences();
});
function updateSubtotal() {
var subtotal = 0;
var start = 32;
$('.math1').each(function(i, el) {
subtotal += parseFloat($(this).find('option:selected').data('price')*start);
});
$('#price').text(subtotal);
};
function updateDifferences() {
$('.math1').each(function(i,sel) {
var $sel = $(sel);
$sel.find('option').each(function(j,opt) {
var $opt = $(opt),
optprice = $opt.data('price'),
selprice = $sel.find('option:selected').data('price'),
diff = optprice * selprice,
diffamount = Math.abs(diff) || "";
$opt.find('.diffaddsubtr').text(diffaddsubtr).end()
});
});
};
});
只要您只使用一个选择框,它就可以很好地工作,但是一旦您使用多个选择框,它就会总结所有的值我该如何改变它,所以它会乘以那里的值
如果您选择 6 人间,价格应为 192 美元,但将是 160 美元
这是我的问题: http: //development.sakesalverda.nl/Hotel/reserveren/(价格会更新但不正确)