Jquery problem hide show div
If i go to http://tourscript.com/hrsportal_last/hotel_details.asp?id=1 and select check in 21 to 24 April i got 2 available rooms. My problem is when i select at least one room from both (eg 1 single and 1 double) you will see the Book button(the proceed ID) a开发者_Go百科ppear but when i select only one i can't get the book button appear ..
The code :
$('#roomOptions select').change(function() {
var total = 0;
$('#roomOptions select').each(function() {
var totprice = $(this).val();
var substr = totprice.split('--');
alert(substr[1]);
total+=parseFloat(substr[1]);
});
if (total > 0) {
$('#proceed').show("slow");
} else {
$('#proceed').hide("slow");
}
$('#roomOptions #roomOptions_total').html(total);
});
Before doing the Split it worked even if i selected one or 2 rooms .. i don't know whay doesn't work anymore. Thank you
You're probably getting a problem through one of the values being undefined. Try this:
$('#roomOptions select').each(function() {
var totprice = $(this).val();
if(totprice) {
var substr = totprice.split('--');
alert(substr[1]);
total+=parseFloat(substr[1]);
}
});
精彩评论