Hi guys and gals,

I am using the following code as a searchbox at the top of my site.

<form name="classic" method="post" action="error.php">
Quicksearch: <input name="INPUT" id="INPUT" type="text" value="" />
<select name="countries" onchange="updatecities(this.selectedIndex); document.classic.action=(this.value)">
<option value="" selected>Choose a category</option>
<option value="search1.php">Category One</option>
<option value="search2.php">Category Two</option>
<option value="search3.php">Category Three</option>
<option value="search4.php">Category Four</option>

<select name="cities">

<input type="image" name="search" src="search.png" />

<script type="text/javascript">

var countrieslist=document.classic.countries
var citieslist=document.classic.cities

var cities=new Array()
cities[2]=["B|bvalue", "C|cvalue", "D|dvalue", "E|evalue"]
cities[3]=["F|fvalue", "G|gvalue"]
cities[4]=["H|hvalue", "J|jvalue"]

function updatecities(selectedcitygroup){
if (selectedcitygroup>0){
for (i=0; i<cities[selectedcitygroup].length; i++)
citieslist.options[citieslist.options.length]=new Option(cities[selectedcitygroup][i].split("|")[0], cities[selectedcitygroup][i].split("|")[1])


This gives me a different secondary dropdown box, based on what is selected in the first box, and then fires off what the user types into INPUT to the relevant search page.

This is included in a seperate php file, and included on every page of my site. My question is, is there a way, once the next page has been loaded to retain the drop down and secondary drop down that were selected by the user, rather that it resetting to the default 'Choose Category'?

There are several ways to do this. The easiest would probably be to use the session array to keep up with the option values. You could also set a cookie with javascript.

I'm not really an advanced coder. Are there any good tutorials I could use to learn how to implement a session array into the above code that you can recommend?

OK, I have found some code on making an array

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<select size="1" name="town">

$towns = array('ipswich','bury', 'eanske');
foreach($towns as $town){
$selected = (isset($_GET['town'])&&$_GET['town']==$town)? '
print("<option value=\"$town\"$selected>$town</option>");
} ?>

<input type="submit" value="GO" />

and it remembers the selected option from page to page. How would I insert this into the previous conditional dropdown menu so that it can remember the selected option across the conditional menu?

Am I just wildly on the wrong track here and there's a great example site with this exact menu on that I could use somewhere and I've been Googling for the wrong terms maybe?