|
-
Mar 27th, 2011, 10:41 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] javascript listbox not working
I've made a taxi fare calculator using google maps, and now im trying to add extra functionality, but i cant get the following code to work.
The idea is that once its calculated and displayed the fare in "txtFare", then to find the fare for a "bus", its selected from the list box and multiply's "txtFare" by '1.50' and displays it in "txtTypeFare".
This function doesn't work, and i can't see why not.
Code:
function calcType() {
var VehType = document.getElementById("sVehicle").innerHTML;
var EstFare = document.getElementById("txtFare").value;
if (VehType = "car")
{document.getElementById("txtTypeFare").value = EstFare};
if (VehType = "estate")
{document.getElementById("txtTypeFare").value = EstFare * 1.25 };
if (VehType = "bus")
{document.getElementById("txtTypeFare").value = EstFare * 1.50};
if (VehType = "exec")
{document.getElementById("txtTypeFare").value = EstFare * 1.75};
}
HTML Code:
<b>Fare: </b>
<input id="txtFare" type="textbox" value="">
<input type="button" value="fare" onClick="calcFare();">
<b>Vehicle: </b>
<select id="sVehicle" onChange="calcType()">
<option value="car">Car</option>
<option value="estate">Estate</option>
<option value="bus">Mini-Bus</option>
<option value="exec">Executive</option>
</select>
<input id="txtTypeFare" type="textbox" value="">
Thanks in advance
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|