Posted by Jonathan N. Little on 09/11/06 13:26
howachen@gmail.com wrote:
> Hi, is it possible to have a pre-defined value for select box which
> mean "select nothing"?
>
> e.g.
>
>
> <select name="cars">
> <option value="volvo">Volvo</option>
> <option value="saab">Saab</option>
> <option value="fiat">Fiat</option>
> <option value="audi">Audi</option>
> </select>
>
> I want to have an option something like <option value="xxx">Please
> Select</option>
Well yes and no. You can certainly have a null value or a token that
means "none", then your receiving script would deal with it
appropriately, but the parameter will show in the query string:
<select name="cars">
<option value="none">Please Select</option>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
....
test.php?car=none&otherParam=something
or
<select name="cars">
<option value="">Please Select</option>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
....
test.php?car=&otherParam=something
The only ways to prevent the param from being in your query string is to
use client-side javascript to remove it (or build the query string) But
this would be a bad idea because it will fail if the client has
javascript disabled. *I would not recommend it.*
The other is use POST instead of GET where the query is not in the URL.
Not sure from your brief snippet whether on not your form is selecting a
resource (GET is appropriate) or transmitting data (POST is appropriate).
--
Take care,
Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
[Back to original message]
|