drop down list problem<

liunx

Guest
I'm doing a drop down list of the states. When the user clicks the submit button, it checks for errors or sends an email. Either way, the page is resent. When it does this, the state selected goes away and the default is there.

Is there any way to keep the state the user selected when the page is refreshed?I'm guessing there are a few ways.

Cookies come straight to mind but from journies in to ASP.NET, this is done for you very easily using the right declarations.

What platform are you using? Possible a backend server language?I'm using PHP on a UNIX server. Is there any PHP code that can retain that value? I can't believe I have to write a cookie or create a session variable when the text fields retain their value.One other thing, I am passing the correct value. Its in the URL.I know relativly little PHP... but I think it will help if we move this to the PHP forum.

There are some guys in there that really know their stuff and sure they will pipe in for you.

Hope you dont mind the move.Originally posted by bufo
One other thing, I am passing the correct value. Its in the URL.
if it is in the url then you need to check for it.
you have your loop to make the select drop down then you need to check for the one that is in the url and see if it is the same

$selected = ($_GET['whatever'] == "state")?"selected = \"selected\"":"";
<option value="whatever" $selected>whatever</option>

but it is hard to tell how you do it.
 
Back
Top