...

View Full Version : need help with multiple choices in if..else statements



learning curve
03-13-2012, 10:38 PM
I need to create javascript that will create the ringup line (see code) based on accomodation selections. If they chose Wednesday as arrival and depart Thursday they will get the breakdown_wed_supplement value. If they arrive Wednesday and depart later than Thursday they will get charged for Wed and Thursday and finally if they arrive Thursday, they will get charge for Thursday. The Friday - Sunday values are working, but I can't get the Wed/Thurs to work. They were written by someone else and were working, but I needed to change it for the Thursday departure. I am really new to javascript and haven't got a clue where I went wrong.



if (getControlValue(form.accommodation)==="Yes") {
if (getControlValue(form.occupancy)==="Single") {
total.ringup(conferencePrices.lodgingFeeConference,'Conference lodging for single person, Friday through Sunday','breakdown_lodging');
} else if (getControlValue(form.occupancy)==="Double") {
total.ringup(conferencePrices.lodgingFeeConferenceRoommate,'Conference lodging with roommate, Friday through Sunday','breakdown_lodging');
}
if (form.arrivedate.selectedIndex===1 && form.departdate.selectedIndex===2) {
if (getControlValue(form.roommate)==="Assign" || form.rm_arrive.selectedIndex===1 && form.rm_depart.selectedIndex===2) {
total.ringup(conferencePrices.lodgingFeeNightlyRoommate,'Wednesday pre-conference lodging, with roommate','breakdown_wed_supplement');
} else {
total.ringup(conferencePrices.lodgingFeeNightly,'Wednesday pre-conference lodging, single person','breakdown_wed_supplement');
}
}

if (form.arrivedate.selectedIndex===1 && form.departdate.selectedIndex===>2) {
if (getControlValue(form.roommate)==="Assign" || form.rm_arrive.selectedIndex===1 && form.rm_depart.selectedIndex===>2) {
total.ringup(conferencePrices.lodgingFeeNightlyRoommate,'Thursday pre-conference lodging, with roommate','breakdown_thurs_supplement');
total.ringup(conferencePrices.lodgingFeeNightlyRoommate,'Wednesday pre-conference lodging, with roommate','breakdown_wed_supplement');
} else {
total.ringup(conferencePrices.lodgingFeeNightly,'Thursday pre-conference lodging, single person','breakdown_thurs_supplement');
total.ringup(conferencePrices.lodgingFeeNightly,'Wednesday pre-conference lodging, single person','breakdown_wed_supplement');
}
}


if (form.arrivedate.selectedIndex===2) {
if (getControlValue(form.roommate)==="Assign" form.rm_arrive.selectedIndex===2) {
total.ringup(conferencePrices.lodgingFeeNightlyRoommate,'Thursday pre-conference lodging, with roommate','breakdown_thurs_supplement');
} else {
total.ringup(conferencePrices.lodgingFeeNightly,'Thursday pre-conference lodging, single person','breakdown_thurs_supplement');
}
}


}

Lerura
03-14-2012, 07:59 AM
I believe the problem is in you comparison operator.

There is no comparison operator ===>

You can see a list and explanation of the diiferent operator at http://www.w3schools.com/js/js_comparisons.asp

learning curve
03-14-2012, 05:52 PM
Thanks lerura. The link you sent was very useful. I will take a step back and try again.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum