lansing
01-26-2006, 04:56 PM
I am working on trying to get a menu option to change based on what another menu option is. I am working on a page that would allow a user to select fluid types for vehicle. I have it working so that the user can select Antifreeze, Motor Oil, Brake Fluid, etc... & then the 2nd menu shows the different brands of Antifreeze, Motor Oil, Brake Fluid, etc... This works just fine...
I now want a 3rd menu to changed based on the brand name chosen. Like when the user clicks the Motor Oil the brands of motor oils appears in the 2nd drop down menu. I want the 3rd menu to display based on the brand that is in the 2nd menu. Like when they choose Motor Oil brand Castrol. The 3rd menu shows the different castrol's lines & oil weights.
This is the coding that I have that doesn't work on the 3 menu. The 2nd menu populates just fine. The values aren't finished. I want to get the functionality working first.
<form action="action.php?do=maintain" method="post" name="maintain_vehicle" id="maintain_vehicle">
<div align="center"> <br>
</div>
<table width="580" height="137" border="1" align="center" bordercolor="#0000FF">
<tr bgcolor="#F2F2F2">
<td height="39" colspan="3"><div align="center">Select the vehicle you want to maintain! </div></td>
</tr>
<tr>
<td height="44" colspan="3" bgcolor="#DAFCFA"> <div align="center">
<select name="vehicle_choosen" id="vehicle_choosen">
<OPTION SELECTED VALUE="">Choose Vehicle to Maintain...
<?php require("cdb.php");
$query_vehicle = mysql_query("SELECT * FROM vehicles ORDER BY `vehicle_year` DESC");
while ($row = mysql_fetch_array($query_vehicle)) {
$vehicle_year = $row["vehicle_year"];
$vehicle_make = $row["vehicle_make"];
$vehicle_model = $row["vehicle_model"];
$vehicle_vin = $row["vehicle_vin"];
?>
<option value="<? echo $vehicle_vin; ?>"> <? echo $vehicle_year; ?> <? echo $vehicle_make; ?> <? echo $vehicle_model; ?>
<? } ?>
</option>
</select>
</div></td>
</tr>
<tr>
<td width="148" height="44" bgcolor="#DAFCFA">
<div align="center"><?php require("maintenance/fluids.php"); ?> </div></td>
<td width="151" bgcolor="#DAFCFA">
<div align="center"><select name="fluid_brand" size="1" id="fluid_brand" onchange="setOptions(document.maintain_vehicle.fluid_brand.options[document.maintain_vehicle.fluid_brand.selectedIndex].value);">
<option value=" " selected="selected">Choose Fluid Brand...</option>
</select></div></td>
<td width="130" bgcolor="#DAFCFA">
<div align="center">
<select name="fluid_weight" size="1" id="fluid_weight" onchange="setFluid_weight(document.maintain_vehicle.fluid_weight.options[document.maintain_vehicle.fluid_weight.selectedIndex].value);">
<option value=" " selected="selected">Choose Fluid Weight...</option>
</select>
</div></td>
</tr>
</table>
<br>
<div align="center">
<input name="maintain" type="submit" id="maintain" value="Save">
<br>
</div>
</form>
This is in the header...<script type="text/javascript">
<!-------START FLUID TYPES----------------->
function setFluids(chosen) {
var selbox = document.maintain_vehicle.fluid_brand;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Choose Fluid Weight...');
}
if (chosen == "Antifreeze") {
selbox.options[selbox.options.length] = new Option('Peak', 'Peak');
selbox.options[selbox.options.length] = new Option('Super Tech', 'Super Tech');
}
if (chosen == "Motor Oil") {
selbox.options[selbox.options.length] = new Option('Castrol','Castrol');
selbox.options[selbox.options.length] = new Option('Pennzoil','Pennzoil');
selbox.options[selbox.options.length] = new Option('Valvoline','Valvoline');
selbox.options[selbox.options.length] = new Option('Kendall','Kendall');
selbox.options[selbox.options.length] = new Option('Royal Purple','Royal Purple');
selbox.options[selbox.options.length] = new Option('Quaker State','Quaker State');
selbox.options[selbox.options.length] = new Option('Havoline','Havoline');
selbox.options[selbox.options.length] = new Option('Quaker State','Quaker State');
selbox.options[selbox.options.length] = new Option('Motorcraft','Motorcraft');
}
if (chosen == "Power Steering Fluid") {
selbox.options[selbox.options.length] = new Option('Castrol','Castrol');
selbox.options[selbox.options.length] = new Option('Pennzoil','Pennzoil');
selbox.options[selbox.options.length] = new Option('Advance Brand','Advance Brand');
selbox.options[selbox.options.length] = new Option('C30 Pickup', 'C30 Pickup');
selbox.options[selbox.options.length] = new Option('Impala','Impala');
}
}
<!--------------END FLUID TYPES------------------>
<!-----------START FLUID WEIGHTS----------------->
function setFluid_weight(chosen) {
var selbox = document.maintain_vehicle.fluid_weight;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Choose Fluid Weight...');
}
if (chosen == "Peak") {
selbox.options[selbox.options.length] = new Option('50/50 Green', '50/50 Green');
selbox.options[selbox.options.length] = new Option('50/50 Red', '50/50 Red');
}
if (chosen == "Super Tech") {
selbox.options[selbox.options.length] = new Option('50/50 Green', '50/50 Green');
selbox.options[selbox.options.length] = new Option('50/50 Red', '50/50 Red');
}
if (chosen == "Castrol") {
selbox.options[selbox.options.length] = new Option('Castrol','Castrol');
selbox.options[selbox.options.length] = new Option('Pennzoil','Pennzoil');
selbox.options[selbox.options.length] = new Option('Valvoline','Valvoline');
selbox.options[selbox.options.length] = new Option('Kendall','Kendall');
selbox.options[selbox.options.length] = new Option('Royal Purple','Royal Purple');
selbox.options[selbox.options.length] = new Option('Quaker State','Quaker State');
selbox.options[selbox.options.length] = new Option('Havoline','Havoline');
selbox.options[selbox.options.length] = new Option('Quaker State','Quaker State');
selbox.options[selbox.options.length] = new Option('Motorcraft','Motorcraft');
}
if (chosen == "Power Steering Fluid") {
selbox.options[selbox.options.length] = new Option('Castrol','Castrol');
selbox.options[selbox.options.length] = new Option('Pennzoil','Pennzoil');
selbox.options[selbox.options.length] = new Option('Advance Brand','Advance Brand');
selbox.options[selbox.options.length] = new Option('C30 Pickup', 'C30 Pickup');
selbox.options[selbox.options.length] = new Option('Impala','Impala');
}
}
<!--------------END FLUID WEIGHTS------------------>
</script>
I now want a 3rd menu to changed based on the brand name chosen. Like when the user clicks the Motor Oil the brands of motor oils appears in the 2nd drop down menu. I want the 3rd menu to display based on the brand that is in the 2nd menu. Like when they choose Motor Oil brand Castrol. The 3rd menu shows the different castrol's lines & oil weights.
This is the coding that I have that doesn't work on the 3 menu. The 2nd menu populates just fine. The values aren't finished. I want to get the functionality working first.
<form action="action.php?do=maintain" method="post" name="maintain_vehicle" id="maintain_vehicle">
<div align="center"> <br>
</div>
<table width="580" height="137" border="1" align="center" bordercolor="#0000FF">
<tr bgcolor="#F2F2F2">
<td height="39" colspan="3"><div align="center">Select the vehicle you want to maintain! </div></td>
</tr>
<tr>
<td height="44" colspan="3" bgcolor="#DAFCFA"> <div align="center">
<select name="vehicle_choosen" id="vehicle_choosen">
<OPTION SELECTED VALUE="">Choose Vehicle to Maintain...
<?php require("cdb.php");
$query_vehicle = mysql_query("SELECT * FROM vehicles ORDER BY `vehicle_year` DESC");
while ($row = mysql_fetch_array($query_vehicle)) {
$vehicle_year = $row["vehicle_year"];
$vehicle_make = $row["vehicle_make"];
$vehicle_model = $row["vehicle_model"];
$vehicle_vin = $row["vehicle_vin"];
?>
<option value="<? echo $vehicle_vin; ?>"> <? echo $vehicle_year; ?> <? echo $vehicle_make; ?> <? echo $vehicle_model; ?>
<? } ?>
</option>
</select>
</div></td>
</tr>
<tr>
<td width="148" height="44" bgcolor="#DAFCFA">
<div align="center"><?php require("maintenance/fluids.php"); ?> </div></td>
<td width="151" bgcolor="#DAFCFA">
<div align="center"><select name="fluid_brand" size="1" id="fluid_brand" onchange="setOptions(document.maintain_vehicle.fluid_brand.options[document.maintain_vehicle.fluid_brand.selectedIndex].value);">
<option value=" " selected="selected">Choose Fluid Brand...</option>
</select></div></td>
<td width="130" bgcolor="#DAFCFA">
<div align="center">
<select name="fluid_weight" size="1" id="fluid_weight" onchange="setFluid_weight(document.maintain_vehicle.fluid_weight.options[document.maintain_vehicle.fluid_weight.selectedIndex].value);">
<option value=" " selected="selected">Choose Fluid Weight...</option>
</select>
</div></td>
</tr>
</table>
<br>
<div align="center">
<input name="maintain" type="submit" id="maintain" value="Save">
<br>
</div>
</form>
This is in the header...<script type="text/javascript">
<!-------START FLUID TYPES----------------->
function setFluids(chosen) {
var selbox = document.maintain_vehicle.fluid_brand;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Choose Fluid Weight...');
}
if (chosen == "Antifreeze") {
selbox.options[selbox.options.length] = new Option('Peak', 'Peak');
selbox.options[selbox.options.length] = new Option('Super Tech', 'Super Tech');
}
if (chosen == "Motor Oil") {
selbox.options[selbox.options.length] = new Option('Castrol','Castrol');
selbox.options[selbox.options.length] = new Option('Pennzoil','Pennzoil');
selbox.options[selbox.options.length] = new Option('Valvoline','Valvoline');
selbox.options[selbox.options.length] = new Option('Kendall','Kendall');
selbox.options[selbox.options.length] = new Option('Royal Purple','Royal Purple');
selbox.options[selbox.options.length] = new Option('Quaker State','Quaker State');
selbox.options[selbox.options.length] = new Option('Havoline','Havoline');
selbox.options[selbox.options.length] = new Option('Quaker State','Quaker State');
selbox.options[selbox.options.length] = new Option('Motorcraft','Motorcraft');
}
if (chosen == "Power Steering Fluid") {
selbox.options[selbox.options.length] = new Option('Castrol','Castrol');
selbox.options[selbox.options.length] = new Option('Pennzoil','Pennzoil');
selbox.options[selbox.options.length] = new Option('Advance Brand','Advance Brand');
selbox.options[selbox.options.length] = new Option('C30 Pickup', 'C30 Pickup');
selbox.options[selbox.options.length] = new Option('Impala','Impala');
}
}
<!--------------END FLUID TYPES------------------>
<!-----------START FLUID WEIGHTS----------------->
function setFluid_weight(chosen) {
var selbox = document.maintain_vehicle.fluid_weight;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Choose Fluid Weight...');
}
if (chosen == "Peak") {
selbox.options[selbox.options.length] = new Option('50/50 Green', '50/50 Green');
selbox.options[selbox.options.length] = new Option('50/50 Red', '50/50 Red');
}
if (chosen == "Super Tech") {
selbox.options[selbox.options.length] = new Option('50/50 Green', '50/50 Green');
selbox.options[selbox.options.length] = new Option('50/50 Red', '50/50 Red');
}
if (chosen == "Castrol") {
selbox.options[selbox.options.length] = new Option('Castrol','Castrol');
selbox.options[selbox.options.length] = new Option('Pennzoil','Pennzoil');
selbox.options[selbox.options.length] = new Option('Valvoline','Valvoline');
selbox.options[selbox.options.length] = new Option('Kendall','Kendall');
selbox.options[selbox.options.length] = new Option('Royal Purple','Royal Purple');
selbox.options[selbox.options.length] = new Option('Quaker State','Quaker State');
selbox.options[selbox.options.length] = new Option('Havoline','Havoline');
selbox.options[selbox.options.length] = new Option('Quaker State','Quaker State');
selbox.options[selbox.options.length] = new Option('Motorcraft','Motorcraft');
}
if (chosen == "Power Steering Fluid") {
selbox.options[selbox.options.length] = new Option('Castrol','Castrol');
selbox.options[selbox.options.length] = new Option('Pennzoil','Pennzoil');
selbox.options[selbox.options.length] = new Option('Advance Brand','Advance Brand');
selbox.options[selbox.options.length] = new Option('C30 Pickup', 'C30 Pickup');
selbox.options[selbox.options.length] = new Option('Impala','Impala');
}
}
<!--------------END FLUID WEIGHTS------------------>
</script>