HTML Select problem

Discussion in 'HTML' started by howachen@gmail.com, Sep 11, 2006.

  1. Guest

    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>

    and when the form get

    it will shown in the query string only IF it was selected.

    e.g.

    test.php?car=Saab

    but the default is just:

    test.php
     
    , Sep 11, 2006
    #1
    1. Advertising

  2. 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
     
    Jonathan N. Little, Sep 11, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGFiYmxlcg==?=

    select gridview row without using select button?

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 3, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    101,607
    dch31969
    Feb 27, 2009
  2. J. Hall
    Replies:
    2
    Views:
    1,106
    Jeff Thies
    Apr 21, 2004
  3. jas

    select.select() on windows

    jas, Oct 25, 2005, in forum: Python
    Replies:
    4
    Views:
    810
    Maksim Kasimov
    Oct 27, 2005
  4. palmiere
    Replies:
    1
    Views:
    452
    Erwin Moller
    Feb 9, 2004
  5. rvelosoo
    Replies:
    1
    Views:
    377
    Bart Van der Donck
    Aug 13, 2008
Loading...

Share This Page