This will work:
<select name="category" id="category" onChange="javascript:document.Form.submit();">
<?
foreach ($categories as $key => $value)
{
echo '<option'; if (isset ($category_id) && $category_id == $key) { echo ' selected';} echo '>' . $value . "\n";
}
?>
</select>
Some notes:
- Ignore the javascript event.
- $categories is an associative array.
- if $category_id is set, it will add selected to the HTML tag, which sets it as default.
You need to step through each option for the menu and when you hit the one that is the current value, make the HTML tag <option selected>
(thanks to devinemke for his help with this and for some sample code!)