You are here:  » Drop Down Menu Showing But Not Working

Support Forum



Drop Down Menu Showing But Not Working

Submitted by jajaj on Wed, 2012-10-03 20:38 in

Hi David

Thanks for all your help to date.

Another question for you:

I have successfully added a drop down menu for categories, using php code I found in the forum.

I have tried to do the same for brands, but am not getting something right, as the drop down items appear, but nothing happens when you click on them.

Could you please take a look at the following code for me to ascertain where I am going wrong?

<?php
  
require("includes/common.php");
  require(
"html/header.php");
  require(
"html/menu.php");
  require(
"html/banner.php");
$sql "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` ORDER by brand";
database_querySelect($sql,$rows);
print 
"<select name='brand'>";
foreach(
$rows as $row)
{
  print 
"<option value='".$row["brand"]."'>".$row["brand"]."</option>";
}
print 
"</select>";
print 
"<noscript><input type='submit' value='Go' /></noscript>";
    print 
"</form>";
?>

Thanks!

Judie

Submitted by support on Thu, 2012-10-04 08:11

Hi Judie,

Have a go with:

print "<form method='GET' action='".$config_baseHREF."search.php'>";
$sql = "SELECT DISTINCT(brand) as brand FROM `".$config_databaseTablePrefix."products` ORDER by brand";
database_querySelect($sql,$rows);
print "<select name='q' onchange='this.form.submit();'>";
foreach($rows as $row)
{
  print "<option value='brand:".urlencode($row["brand"])."'>".$row["brand"]."</option>";
}
print "</select>";
print "<noscript><input type='submit' value='Go' /></noscript>";
print "</form>";

I added the opening FORM tag, and also the onchange attribute to the SELECT tag, which needs to have name="q" to submit to the search.php...

Cheers,
David.
--
PriceTapestry.com

Submitted by jajaj on Fri, 2012-10-05 11:47

Hi David

That works fine, thanks!

Judie