I need to add the OptionPricing variable to the 2: 258 which is in the var AccompPricing, in this script. I want to write something like this 2: 258 + (var Price), but it doesn't work like that. The total package should be added to the second choices value. Example: 258 + The price the package = 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); });
Price
toAccompPricing[2]
? BecauseupdateTotal
already basically does that. It gets the price back fromcheckOptions
and adds it to the amount from the appropriate index ofAccompPricing
. So just removing the+ var Price
from theAccompPricing
object initializer would seem sufficient. So it's really not clear why you think you want something there, or what you're trying to do.checkOptions
based on which entry inAccompPricing
gets used?