[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
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.
:wave:
Re: help with if statements please