Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    7
    Thanked 0 Times in 0 Posts

    need help with multiple choices in if..else statements

    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.

    Code:
    		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');
    	}
    	}
    	
    
    	}

  • #2
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    908
    Thanks
    0
    Thanked 120 Times in 119 Posts
    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

  • #3
    New Coder
    Join Date
    Mar 2012
    Posts
    18
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Thanks lerura. The link you sent was very useful. I will take a step back and try again.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •