I have a footer with 3 menus. Each are dependent. Make, Model, and Year.
When user selects make (onchange event) model updates.
When user selects Model (onchange event) year updates.
Once the user has selected Make, model, and Year and submits it using the submit button it will go to the form and update the actual listings.
Any help would be awesome!
Right now its setup that onchange submits the new url which changes the listings being viewed. But does update the list menus. I want just the list menus to update.
[code=php]
<form name=”filter_form” method=”get” action=”search_filter.php” id=”footer_sub”>
<ul id=”searchfilter”><li>
<select id=”make” name=”make” onchange=”location.href=’search_filter.php?make=’+filter_form.make.options[selectedIndex].value+’&userZip=<?php echo $userZip; ?>&model=model_all&year=year_all&distance=<?php echo $distance; ?>'”>
<?php
if (isset($_GET[‘make’])) {
$result=mysql_query(“SELECT DISTINCT make FROM listings order by make”) or die(mysql_error());
while($query_data = mysql_fetch_assoc($result)) {
$mk = $query_data[‘make’];
//if a make was selected and matches the one in the qry row,
//set the option’s selected attribute
$selected = ($_GET[‘make’] == $mk) ? ‘ selected=”selected”‘ : ”;
echo “<option value=”$mk”$selected>$mk</option>”;
}
}
?>
</select>
</li><!–END OF MAKE–>
<li><select id=”model” name=”model” >
<option selected=”selected” value=”model_all” onchange=”location.href=’search_filter.php?make=<?php echo $make; ?>&userZip=<?php echo $userZip; ?>&model=’+filter_form.model.options[selectedIndex].value+’&year=year_all&distance=<?php echo $distance; ?>'”>All Models</option>
<?php
if (isset($_GET[‘make’])) {
$result = mysql_query(“SELECT DISTINCT model FROM listings WHERE make =’$make’ ORDER BY model”) or die(mysql_error());
while($query_data = mysql_fetch_assoc($result)) {
$md = $query_data[‘model’];
//if a make was selected and matches the one in the qry row,
//set the option’s selected attribute
$selected = ($_GET[‘model’] == $md) ? ‘ selected=”selected”‘ : ”;
echo “<option value=”$md”$selected>$md</option>”;
}
}
?>
</select>
</li><!–END OF MODEL–>
<li><select id=”year” name=”year”>
<option selected=”selected” value=”year_all”>All Years</option>
<?php
if ($_GET[‘model’] == “model_all” ) {
$result = mysql_query(“SELECT DISTINCT year FROM listings WHERE make =’$make’ ORDER BY year DESC”) or die(mysql_error());
}
if ($_GET[‘model’] != “model_all” ) {
$result = mysql_query(“SELECT DISTINCT year FROM listings WHERE make =’$make’ and model =’$model’ ORDER BY year DESC”) or die(mysql_error());
}
while($query_data = mysql_fetch_assoc($result)) {
$yr = $query_data[‘year’];
//if a make was selected and matches the one in the qry row,
//set the option’s selected attribute
$selected = ($_GET[‘year’] == $yr) ? ‘ selected=”selected”‘ : ”;
echo “<option value=”$yr”$selected>$yr</option>”;
}
?>
</select><!–END OF YEAR–>
</li>
<li>
<input value=”submit” type=”submit”/>
</li>
</ul>
</form>