I have a problem…..
when clicking on .aa it makes the elements and with the help of seattist['seats'][column][row]['price'] counts the price and shows the general price in $(".checkout_area")
there is a $(".desc2 a") button in each, and when clicking on it, it should subtract the seatlist['seats'][column][row]['price'] from the general price and show it in the $(".checkout_area"), I’ve written it there, but I don’t know why, it doesn’t work…
have any suggestions.
thank you
var ipl = 1;
var price = 0;
var createNewElem = function(obj) {
var column = obj.parent().children().index(obj.get(0));
var row = obj.parent().parent().children().index(obj.get(0).parentNode);
++ipl;
if (!$(obj.attr("rel")) || $(obj.attr("rel")).size() < 1) {
obj.attr("rel", "#cc_" + ipl);
$(".seat_desc")
.append("<div id='cc_" + ipl + "' class='desc2'>" +
"<p class='section_s'>" + seatlist['seats'][column][row]['sector'].replace(/sector\s/, '') + "</p>" +
"<p class='row_r'>" + seatlist['seats'][column][row]['row'].replace(/Row\s/, '') + "</p>" +
"<p class='seat_s'>" + seatlist['seats'][column][row]['seat'].replace(/seat\s/, '') + "</p>" +
"<a href='#'>remove</a>" +
"<span> CA $" + seatlist['seats'][column][row]['price'] + "</span>" +
"<div class='clear'></div>" +
"</div>");
price += seatlist['seats'][column][row]['price'];
$(".checkout_area").html("SUBTOTAL: CA $" + price);
} else {
$(obj.attr("rel")).remove();
obj.attr("rel", "");
price -= seatlist['seats'][column][row]['price'];
$(".checkout_area").html("SUBTOTAL: CA $" + price);
}
};
$(".aa").click(function() {
createNewElem($(this));
});
$(".desc2 a").live("click", function() {
var column = $(this).parent().children().index(this);
var row = $(this).parent().parent().children().index(this.parentNode);
$(this).parent("div").remove();
$(".seat p span").html($(".desc2").length);
$(".checkout_area").html("SUBTOTAL: CA $" + price - seatlist['seats'][column][row]['price']);
return false;
});
1 Answer