Re: How do I keep the selected showing...
| From: | Brett | Date: | Sun, 04 Mar 2001 03:16:58 +0000 |
| Subject: | Re: How do I keep the selected showing... | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-7100@lists.php.net to get a copy of this message | ||
> > Hi All
> > I have a fully functional db site which uses 2 sqls and 1 page to give
our
> > visitors info they need.
> >
> > That works fine, but some users have remarked that it would be nice that
> the
> > selected item from our drop down list stays shown when the page gives
the
> > info instead of going back to the top of the list.
> >
> > http://www.angelettes.co.uk/dates/index.php3 is the url in
> > action and
> > choosing different towns will show you what I mean.
> >
> > Its not the end of the world, as our visitors have said, but would be
> nice.
> >
> > Any help is full appreciated.
> >
> > Dave C
Check if the variable has been posted and echo the value like below on the
first option line is how I do it. This will put two options with the same
value in the select box and the first will be selected.
<? if(isset($HTTP_POST_VARS["variable"])) echo '<option
value="'.$HTTP_POST_VARS["variable"].'"
selected>'.$HTTP_POST_VARS["variable"].'</option>'; ?>
or add to each option: if ($HTTP_POST_VARS["variable"] == 'option
value')echo 'selected';
example:
<option value="value" <?if ($HTTP_POST_VARS["variable"] == 'option
value')echo 'selected'; ?>>some text</option>
HTH,
Brett