Hi there?
I'm trying to work out what my options are for reloading a page from a click event on a combo.
The code below loads a list of product groups. I want to select a group in the combo and reload the page with the same group selected in the combo and then add a table of products in that group.
Do I use javascript 'onClick' event then form.submit or something?
Any help would be muchly appreciated
<?
$db_name = "WebSiteDB";
$table_name = "products";
$connection = @mysql_connect("localhost", "myname", "mypass") or die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql = "SELECT DISTINCT product_family FROM $table_name";
$result = @($sql,$connection) or die("Couldn't execute query.");
while ($row = mysql_fetch_array($result)) {
$category = $row['product_family'];
if (!$product_category == $category) {
$option_block .= "<option value=\"$category\">$category</option><br>\n";
} else {
$option_block .= "<option value=\"$category\" selected>$category</option><br>\n";
}
}
?>
<HTML><HEAD><TITLE> List Products</TITLE></HEAD><BODY>
<FORM NAME="combo_select" METHOD="post" action=$PHP_SELF>
<select name="product_category">
<? echo "$option_block"; ?>
</select>
</form>
</BODY>
</HTML>
Have a nice day!