Dropbox (keeping selected option after refresh)

Ok I have a dropbox like this


<td>
<div align="left">Map Control: <br>
<select name="zoom">
<option value="5" [zoom_5_select]>Zoom In 5x</option>
<option value="4" [zoom_4_select]>Zoom In 4x</option>
<option value="3" [zoom_3_select]>Zoom In 3x</option>
<option value="2" [zoom_2_select]>Zoom In 2x</option>
<option value="1" [zoom_1_select] selected="selected">Recenter</option>
<option value="-2" [zoom_-2_select]>Zoom Out 2x</option>
<option value="-3" [zoom_-3_select]>Zoom Out 3x</option>
<option value="-4" [zoom_-4_select]>Zoom Out 4x</option>
<option value="-5" [zoom_-5_select]>Zoom Out 5x</option>
</select>
</div><br>
</td>


Currently on the first pageload it goes to "Recenter", thats fine and I want it to stay like this. However after every refresh it goes back to the "Recenter" option but I want it to go to whichever option was the last selected from the box.

Any help on this would be greatly appreciated.

Thanks Brad<form> </form>


?

not sure if those are needed.....Sorry for not specifying but in the full html file it is within a form.We need more code. Please post the full HTML and JavaScript. Are you using Google or Yahoo Maps? Is this something completely custom coded by you? If you use server side scripting, what language are you using? You may be able to use cookies, but depending on your server side and client side implementation, cookies may not be the most ideal.<html>
<head>
<title>De Bortoli Wines MapServer</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="800" height="600" align="center" border="0">
<tr>
<td>
<form name="mapserv" method="GET" action="/cgi-bin/mapserv">
<input type="hidden" name="map" value="/usr/local/mapfiles/dbw.map">
<input type="hidden" name="imgext" value="418485.188 6204834.362 424295.450 6208828.520">
<input type="hidden" name="imgxy" value="320 240">
<input type="hidden" name="mode" value="browse">
<table width="70%" align="left" border="1">
<tr>
<td align="center" valign="top">
<input type="image" name="img" src=http://www.webdeveloper.com/forum/archive/index.php/"" width="640" height="480" border="0">
</td>
</tr>
</table>
<table align="right" border="1">
<tr>
<td>
<p>Reference:<br>
<input type="image" name="ref" src=http://www.webdeveloper.com/forum/archive/index.php/"[ref]" border="0"></p>
</td>
</tr>
<tr>
<td>Select Layers:<br>
<input type="checkbox" name="layer" value="cadbd">Cadastral Boundary<br>
<input type="checkbox" name="layer" value="propbd">Property Boundary<br>
<input type="checkbox" name="layer" value="fmbl">Farm Blocks<br>
<input type="checkbox" name="layer" value="varbl">Variety Blocks<br>
</td>
</tr>
<tr>
<td>
<div align="left">Map Control: <br>
<select name="zoom">
<option value="5">Zoom In 5x</option>
<option value="4">Zoom In 4x</option>
<option value="3">Zoom In 3x</option>
<option value="2" >Zoom In 2x</option>
<option value="1" selected="selected">Recenter</option>
<option value="-2">Zoom Out 2x</option>
<option value="-3" >Zoom Out 3x</option>
<option value="-4" >Zoom Out 4x</option>
<option value="-5" >Zoom Out 5x</option>
</select>
</div><br>
</td>
</tr>
</form>
<tr>
<td>
<p>Legend:<br>
<img src=http://www.webdeveloper.com/forum/archive/index.php/"../legend.gif" width="159" height="77" border="0">
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>


Ok here is the code it is a custom template file for Mapserver and I am using Apache with PHP enabled, so I can use HTML, Javascript and PHP.Use PHP. Keep a zoomvalue in the user's session. Build the select with a PHP loop. When the option value equals the zoomvalue add the selected attribute to the option.write a cookie?
 
Back
Top