
December 13th, 1999, 08:58 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
Does anybody know how to make drop down boxes stay selected after doing a search?
I have a keyword search set up on my regional search engine. The search function not only uses keywords to search, it also uses 2 drop down boxes. vFor instance let's say you were looking for "Cheap" "real estate" in "Fort Collins." First, you would click the category drop down menu "Real Estate," then you would click the city drop down menu "Fort Collins" and finally enter the keyword "Cheap" into the search field.
The search results page works fine, however it would cool if the drop down boxes stayed selected (i.e. Real Estate, Fort Collins, and not to push it, but it would be really cool if the keywords stayed in the search field too).
You can see it in action if you go here: http://johnny.ncolorado.com/youwontguess.php3.
Here's the code:
<?
$sql = " SELECT * FROM cities ORDER BY city";
$city_result = mysql("nco", $sql);
$city_num = mysql_numrows($city_result);
?>
<?
$sql = " SELECT categories.*, categoryparent.category_id";
$sql .= " FROM categories,categoryparent";
$sql .= " WHERE categories.category_id=categoryparent.category_id";
$sql .= " && categoryparent.parent_id=0";
$sql .= " ORDER BY category";
$categories_result = mysql("nco", $sql);
$categories_num = mysql_numrows($categories_result);
$catpercolumn = round($categories_num / 2);
?>
<FORM ACTION="nc_results.php3" ENCTYPE="x-www-form-encoded" METHOD="POST">
<CENTER><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="600" >
<TR VALIGN=TOP>
<TD ALIGN=RIGHT WIDTH="15"><IMG SRC="images/ncsearchleftround.gif" HEIGHT=55 WIDTH=13></TD>
<TD WIDTH="570" BGCOLOR="#CC9900">
<CENTER><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%" >
<TR VALIGN=TOP>
<TD><B><FONT FACE="Arial,Helvetica"><FONT COLOR="#5F4B7C"><FONT SIZE=-1>
Choose A City</FONT></FONT></FONT></B></TD>
<TD><B><FONT FACE="Arial,Helvetica"><FONT COLOR="#5F4B7C"><FONT SIZE=-1>Pick
A Category</FONT></FONT></FONT></B></TD>
<TD><B><FONT FACE="Arial,Helvetica"><FONT COLOR="#5F4B7C"><FONT SIZE=-1>Enter
Keywords</FONT></FONT></FONT></B></TD>
<TD><IMG SRC="images/dell2.gif" HEIGHT=13 WIDTH=101></TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<!--Start City Drop Down List-->
<TD> <SELECT name = "city_id"><OPTION value="all">All Cities
<? $i = 0; while ($i < $city_num) { ?>
<OPTION value="<? echo mysql_result($city_result, $i, "city_id"); ?>"><FONT FACE="Arial,Helvetica"><FONT COLOR="#000000"><FONT SIZE=-1><? echo mysql_result($city_result, $i, "city"); ?>
<? $i++; } ?>
</SELECT> </FONT></FONT></FONT></TD>
<!--End City Drop Down List-->
<!--Start Category Drop Down List-->
<TD><SELECT name="category_id"><OPTION value="all">All Categories
<? $i = 0; while ($i < $categories_num) { ?>
<OPTION value="<? echo mysql_result($categories_result, $i, "category_id"); ?>"><FONT FACE="Arial,Helvetica"><FONT COLOR="#000000"><FONT SIZE=-1><? echo mysql_result($categories_result, $i, "category"); ?>
<? $i++; } ?>
</SELECT> </FONT></FONT></FONT></TD>
<!--End Category Drop Down List-->
<TD><INPUT type="text" Name="keywordsearch" size="22">
</TD>
<TD> <INPUT TYPE="submit" NAME="submit" VALUE="Search"></TD>
</TR>
</TABLE></CENTER>
</TD>
<TD ALIGN=LEFT WIDTH="15"><IMG SRC="images/ncsearchrightround.gif" HEIGHT=55 WIDTH=13></TD>
</TR>
<TR ALIGN=RIGHT>
<TD></TD>
<TD><FONT FACE="Arial,Helvetica"><FONT SIZE=-1><A HREF="about.php3">What
Is This?</A> | </FONT> <FONT SIZE=-1><A HREF="addsite.php3">Add Your
Site</A></FONT></FONT> | <FONT FACE="Arial,Helvetica"><FONT SIZE=-1>
<A HREF="feedback.php3">Feedback</A> | <A HREF="faq.php3">Frequently Asked
Questions</A> | <A HREF="faq.php3">Help</A> | <A HREF="searchtips.php3">Search
Tips</A></FONT></FONT></TD>
<TD></TD>
</TR>
</TABLE>
</CENTER>
</FORM>
|