我需要在此脚本中将 OptionPricing 变量添加到 var AccompPricing 中的 2: 258。我想写这样的东西 2: 258 + (var Price),但它不是那样工作的。总包应添加到第二个选择值。示例:258 + 包裹价格 = Total #2。
// Collect Data & Prices To Update Dynamic Prices
var OptionPricing = {
'pack11049': 1049,
'pack21199': 1199,
'pack31199': 1199,
'pack41299': 1299,
'pack51449': 1449,
'pack61499': 1499,
'pack71549': 1549,
'pack81699': 1699,
'pack91799': 1799,
'pack101999': 1999,
'pack112499': 2499,
'pack122549': 2549
};
function checkOptions() {
var Price = 0;
for (Packs in OptionPricing) {
if ($('#' + Packs).is(':checked')) {
Price += OptionPricing[Packs];
}
}
return Price;
}
var AccompPricing = {
0: 0,
1: 129,
2: 258 + (var Price),
3: 1057,
4: 1856
};
function checkAccomp() {
var Accomp = parseInt($('#howmany').val(), 10);
return AccompPricing[Accomp];
}
function updateTotal() {
var ThePrice = checkOptions() + checkAccomp();
$('#TotalPrice').text('$' + ThePrice + '.00');
}
$(function () { $('.DoPricing').click(updateTotal); });