23
rated 0 times
[
30]
[
7]
/ answers: 1 / hits: 15441
/ 10 Years ago, mon, october 6, 2014, 12:00:00
I am calling a function called getPrice() in javascript file by using onChange() command in tag in HTML file, but no matter what I do or fix, it still doesnt show the price. I have done a lot of research but cant seem to find any correct solutions. Helps will be greatly appreciated.
Here is my HTML code:
<body>
<form action=# name=ITSbookform id=ITSform>
<fieldset>
<legend>Into The Storm Booking</legend>
<label>Choose your cinema</label><br>
<select id=selectedCinema>
<option>--Select--</option>
<option value=maximaCinema>Maxima Cinema</option>
<option value=rivolaCinema>Rivola Cinema</option>
</select><br>
<label>Select day and time</label>
<select id=dayAndTime>
</select>
<br>
<label>Select Seat</label>
<select id=selectedSeat onchange=getPrice()>
</select>
<p id=total>Total Price: </p>
</form>
</fieldset>
</body>
and the Javascipt part:
function getPrice(){
var totalPrice = 0;
if(document.getElementById(selectedCinema).value == maximaCinema){
if(document.getElementById(dayAndTime).value == 9pmMonday || document.getElementById(dayAndTime).value == 9pmTuesday){
seatPrice[full] = 12;
seatPrice[conc] = 10;
seatPrice[child] = 8;
seatPrice[FirstClass-Adult] = 25;
seatPrice[FirstClass-Child] = 20;
seatPrice[beanbag] = 20;
}
else{
seatPrice[full] = 18;
seatPrice[conc] = 15;
seatPrice[child] = 12;
seatPrice[FirstClass-Adult] = 30;
seatPrice[FirstClass-Child] = 25;
seatPrice[beanbag] = 30;
}
}
else{
seatPrice[adult] = 18;
seatPrice[conc] = 15;
seatPrice[child] = 12;
}
var seat = theForm.elements[selectedSeat];
totalPrice = seatPrice[seat.value];
document.getElementById(total).innerHTML = $ + totalPrice;
}
and here is the full version of the code in JSFiddle: http://jsfiddle.net/stb0v5Ln/
Thank you.
More From » jquery