Results 1 to 3 of 3

Thread: [RESOLVED] help with if statements please

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    Resolved [RESOLVED] help with if statements please

    Im back working on improving my taxi fare calculator, I'm trying to create a number of set fares, if you take a look at the code its pretty self explanatory. I get as far as 123 showing as the fare, so i think i've messed up the if statements.

    Code:
    	function CheckSetFare() {
    		var PickupTown = document.getElementById("input_3_city").value;//get town/city data from pickup
    		var DestinationTown = document.getElementById("input_8_city").value;//get town/city data from destination
    		var DestinationAddress = document.getElementById("j-destination").value;// get destination address data
    		var PickupAddress = document.getElementById("j-address").value;// get pickup address data		
    		var InitFare = 123;
    		
    		if(PickupTown == "Heywood" + DestinationAddress == " Manchester Airport "){InitFare = 25};//Heywood-ManA-£25.
    		if(DestinationTown == "Heywood" + PickupAddress == "Manchester Airport"){InitFare = 27};//ManA-Heywood-£27.
    		
    		document.getElementById("initial-fare").value = InitFare;//replace quoted fare with new set fare for car.
    		document.getElementById("input_18").value = InitFare;//replace quoted fare with new set fare for car.
    	}
    Thanks Chris1990
    If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.

    If you fail, try and try again, its the only way to success.

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: help with if statements please

    Try this:
    Code:
    if(PickupTown == "Heywood" && DestinationAddress == "Manchester Airport") {InitFare = 25;}//Heywood-ManA-£25.
    else if(DestinationTown == "Heywood" && PickupAddress == "Manchester Airport") {InitFare = 27;}//ManA-Heywood-£27.

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    Re: help with if statements please

    thanks it worked
    If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.

    If you fail, try and try again, its the only way to success.

Posting Permissions

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



Click Here to Expand Forum to Full Width