Hi,
I have the following bit of code which gets values for a database and populates a dropdown box. What I want to do is when this is changed, pass the relevant value back to the page so it can be used to update another dropdown box.
function chassis_dropdown($page)
{
//dropdown box for chassis
global $selectedchassis;
global $chassis;
$chassis_result = mysql_query ("SELECT DISTINCT chassis FROM models");
$num_chassis = mysql_num_rows($chassis_result);
$chassisarray = array();
//use the for loop to populate the array with the unitnos from the query
for ($i=0; $i<$num_chassis; $i++)
{
$chassis_row=mysql_fetch_object($chassis_result);
$chassisarray[]=$chassis_row->chassis;
}
//start the dropdown box
echo "<select name=\"chassis\" value=\"$chassis\" onChange=\"location.href='$page?selectedchassis=$chassis\">";
if (isset ($selectedchassis))
{
echo "<option value=\"\">SELECT CHASSIS</option>";
}
else
{
echo "<option value=\"\" SELECTED>SELECT CHASSIS</option>";
}
echo "<option value=\"%\">ALL CHASSIS</option>";
//populate the option and provide a SELECTED option for each item in the array
foreach ($chassisarray as $item)
{
$chassis = $item;
if ($selectedchassis == $item)
{
echo "<option value=\"$item\" SELECTED>$item</option>";
}
else
{
echo "<option value=\"$item\" >$item</option>";
}
}
echo "</select>";
}
The problem is, that although the dropdown box is refreshing the page, it doesn't seem to be passing the variable back. Any Ideas?
Thanks in advance. Jo