我试图计算一个座位的成本取决于选择的数量,问题是第一个座位的成本与其余部分不同。
第一个= 2250 额外座位收费为995
我的语法和计算应该是什么?
//seats variable
var costOfSeats;
//Calculate cost of seats and display cost of seats
$('#range--seats').on("change", function() {
if ($(this).val(1)) {
costOfSeats == 2250;
} else {
costOfSeats == costOfSeats + ($(this).val(-1) * 995);// problem here
}
$('.output--seats').val("£" + costOfSeats);
}).trigger("change");
答案 0 :(得分:1)
var n = 3; //number of seats
var sum = 0;
var extraSeat = 995;
var seat = 2250;
if (n != 0) {
sum = seat + ((n-1) * extraSeat)
}
答案 1 :(得分:0)
RewriteEngine On RewriteCond %{THE_REQUEST} \s/+article/detail/59[/?\s] [NC] RewriteRule ^ /article/detail/What_Causes_Baby_Diarrhea? [R=301,L] # rest of your rule go here
您使用的是if ($(this).val(1)) {
costOfSeats == 2250;
} else {
costOfSeats == costOfSeats + ($(this).val(-1) * 995);// problem here
}
,而不是costOfSeats == costOfSeats
。您正在比较值而不是分配它们