Hi,
I have this example which works in IE Explorer, but not in Firefox. What changes do I make in the JS code to make it work both in IE and Firefox?
In the Firefox, I get the alert messages in the JS function, but there is no display of the div containers.
Thanks.
I have this example which works in IE Explorer, but not in Firefox. What changes do I make in the JS code to make it work both in IE and Firefox?
In the Firefox, I get the alert messages in the JS function, but there is no display of the div containers.
Thanks.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] >
<head>
<title>Show and Hide Function</title>
<script type="text/javascript">
function togDisplay(argState) {
argState = String(argState);
alert(argState);
switch (argState) {
//Pass the option value of the Select Control. Based on the value, show the div you would like to display and hide the others.
case "Car":
showCars.style.display = "block";
showTrucks.style.display = "none";
showSUV.style.display = "none";
break;
case "PickUpTruck":
showCars.style.display = "none";
showTrucks.style.display = "block";
showSUV.style.display = "none";
break;
case "SUV":
showCars.style.display = "none";
showTrucks.style.display = "none";
showSUV.style.display = "block";
break;
}
}
</script>
</head>
<body>
Select Vehicle Type:
<select name="sVehicle" id="sVehicle" onChange="togDisplay(this.value);">
<option value="">Select Vehicle Type</option>
<option value="Car">Car</option>
<option value="PickUpTruck">Pick Up Trucks</option>
<option value="SUV">SUV</option>
</select>
<div id="showCars" style="display:none">
Enter Car Type: <input type="text" name="Car1" id="Car1" size="50" /><br />
Enter Car Type: <input type="text" name="Car2" id="Car2" size="50" /><br />
Enter Car Type: <input type="text" name="Car3" id="Car3" size="50" /><br />
</div>
<div id="showTrucks" style="display:none">
Enter Truck Type: <input type="text" name="Truck1" id="Truck1" size="50" /><br />
Enter Truck Type: <input type="text" name="Truck2" id="Truck2" size="50" /><br />
Enter Truck Type: <input type="text" name="Truck3" id="Truck3" size="50" /><br />
</div>
<div id="showSUV" style="display:none">
Enter SUV Type: <input type="text" name="SUV1" id="SUV1" size="50" /><br />
Enter SUV Type: <input type="text" name="SUV2" id="SUV2" size="50" /><br />
Enter SUV Type: <input type="text" name="SUV3" id="SUV3" size="50" /><br />
</div>
</body>
</html>