HTML Multiple Select

Discussion in 'Java' started by Akshat Trivedi, Feb 18, 2005.

  1. Hi,

    I am trying to create a dropdown menu in HTML using the <SELECT> tag. I
    need to select multiple items but the constraint I have is that the
    size has to be 1.

    <select name="3" multiple size="1">
    <option>one
    <option>two
    <option>three
    <option>four
    <option>five
    <option>six
    </select>

    With the above approach I do not get a drop down but a list with only 1
    option visible. I need the dropdown and multiple select. The dropdown
    menu could have a scroll bar in it. Can someone suggest a solution.

    Thanks,
    AT
     
    Akshat Trivedi, Feb 18, 2005
    #1
    1. Advertising

  2. Akshat Trivedi

    Peter Kirk Guest

    "Akshat Trivedi" <> skrev i en meddelelse
    news:...
    > I am trying to create a dropdown menu in HTML using the <SELECT> tag. I
    > need to select multiple items but the constraint I have is that the
    > size has to be 1.
    >
    > <select name="3" multiple size="1">
    > <option>one
    > <option>two
    > <option>three
    > <option>four
    > <option>five
    > <option>six
    > </select>
    >
    > With the above approach I do not get a drop down but a list with only 1
    > option visible. I need the dropdown and multiple select. The dropdown
    > menu could have a scroll bar in it. Can someone suggest a solution.


    You have posted to a Java group - maybe better to find one that deals with
    HTML
    Here is a site about HTML:
    http://www.htmlcodetutorial.com/forms/_SELECT.html
     
    Peter Kirk, Feb 18, 2005
    #2
    1. Advertising

  3. Akshat Trivedi

    Roland Guest

    On 18-2-2005 15:14, Akshat Trivedi wrote:
    > Hi,
    >
    > I am trying to create a dropdown menu in HTML using the <SELECT> tag. I
    > need to select multiple items but the constraint I have is that the
    > size has to be 1.
    >
    > <select name="3" multiple size="1">
    > <option>one
    > <option>two
    > <option>three
    > <option>four
    > <option>five
    > <option>six
    > </select>
    >
    > With the above approach I do not get a drop down but a list with only 1
    > option visible. I need the dropdown and multiple select. The dropdown
    > menu could have a scroll bar in it. Can someone suggest a solution.
    >
    > Thanks,
    > AT
    >

    Since it has nothing to do with Java, you'd better ask this in a group
    like comp.infosystems.www.authoring.html
    --
    Regards,

    Roland de Ruiter
    ___ ___
    /__/ w_/ /__/
    / \ /_/ / \
     
    Roland, Feb 18, 2005
    #3
  4. Akshat Trivedi

    Tom Dyess Guest

    "Akshat Trivedi" <> wrote in message
    news:...
    > Hi,
    >
    > I am trying to create a dropdown menu in HTML using the <SELECT> tag. I
    > need to select multiple items but the constraint I have is that the
    > size has to be 1.
    >
    > <select name="3" multiple size="1">
    > <option>one
    > <option>two
    > <option>three
    > <option>four
    > <option>five
    > <option>six
    > </select>
    >
    > With the above approach I do not get a drop down but a list with only 1
    > option visible. I need the dropdown and multiple select. The dropdown
    > menu could have a scroll bar in it. Can someone suggest a solution.
    >
    > Thanks,
    > AT
    >


    I don't think a multiple select is possible with a combobox/dropdown in
    current HTML standards. It's either combobox which is a single selection, or
    a multiselect which looks like a textarea. I would check the HTML newsgroups
    or google.com to make sure though.

    ---
    Tom Dyess
    OraclePower.com
     
    Tom Dyess, Feb 18, 2005
    #4
  5. Akshat Trivedi

    richard1234

    Joined:
    Jul 12, 2008
    Messages:
    3
    use php instead

    I use php for webforms :flute:

    java is much too complicated! :-(

    use java for more computational things,
    for GUI things just use php


    eg here is a php program to echo an element
    of name xyz from a webform in php say echo_xyz.php


    <?php

    echo $_REQUEST[ "xyz" ] ;

    ?>


    that will deal with GET and POST etc. it doesnt get
    any simpler than that. You need the more recent versions
    of php for _REQUEST[]. But all servers will have recent
    php's.

    furthermore people CANNOT view files which end in .php
    as the server executes them regardless of directory.

    its not like perl where the scripts have to go in /cgi-bin



    multiple select looks complicated,

    here is a php page which seems to explain both the html and php:

    http://www.onlinetools.org/tricks/using_multiple_select.php

    as you can see, the php is advanced but straightforward.

    I recommend you use _REQUEST instead of _POST
    as _POST only deals with POST actions, _REQUEST
    is a more recent addition to php which deals with all cases.

    earlier php's needed a complicated function to
    unify the different html form actions.


    I guess you have to use the Java version of that php,

    it must be very tricky to do in Java which is why noone
    here has an answer!
     
    richard1234, Jul 12, 2008
    #5
  6. Akshat Trivedi

    richard1234

    Joined:
    Jul 12, 2008
    Messages:
    3
    full working example via php

    :damnmate:

    I realise this is a Java thread!

    if you want to create a graph for a financial website
    you use Java, :stupido:

    but for the problem here you use php, which
    answers the original question. 8)

    experimenting with the URL I gave above I
    have a debugged complete example how to do it via
    HTML and php.

    you need 2 files: multi.html and multi.php
    which can be placed in any directory of
    a website. furthermore your PC doesnt need php,
    the interesting thing about php is it is all done
    at the server. for instance it means noone
    can steal your php code and it should run
    with most computers.

    -------------------------------------------
    multi.html is:

    <html>
    <head>
    <title>multi</title>
    </head>
    <body>


    <form method="post" action="multi.php">

    <p>menu:
    <select name="car[]" multiple="multiple">
    <option value="mercedes">mercedes</option>

    <option value="vw">vw</option>

    <option value="audi" selected>audi</option>

    <option value="trabant" selected>trabant</option>

    </select>

    <input type="submit">

    </form>


    </body>
    </html>

    ----------------------------------------------------

    multi.php is:

    <?php

    $cars=$_REQUEST['car'];

    if( $cars )
    {
    foreach( $cars as $car ){ echo $car ; echo " " ; }
    }

    ?>

    ------------------------------------------------------------

    with the example you visit multi.html with a browser,
    make a multiple selection of the cars you want, press submit
    and it will list the cars selected separated by spaces. :captain:

    I avoided using unnecessary php constructs. :veryprou:

    like Java, php also uses the C syntax. php can be
    intermixed with HTML and that is where a lot of the
    power is: you can use HTML <form> to give php
    GUI functionality.

    to see the power of php I wrote a simple mailing list
    program in maybe 20 lines of php. it is a 1-way mailing
    list which emails everyone in the list but replies
    go to a different address. the script sends an email

    with the persons name in the subject line and

    hi richard,

    ....

    as the message.


    on the HTML side people are recommended to use
    checkboxes instead of multi-select menus as
    checkboxes can be processed much more powerfully
    as you can access each checkbox directly.

    :saint:
     
    richard1234, Jul 13, 2008
    #6
  7. Akshat Trivedi

    richard1234

    Joined:
    Jul 12, 2008
    Messages:
    3
    richard1234, Jul 13, 2008
    #7
    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. The Legend
    Replies:
    0
    Views:
    734
    The Legend
    Aug 7, 2005
  2. palmiere
    Replies:
    1
    Views:
    466
    Erwin Moller
    Feb 9, 2004
  3. Ferd Berfel
    Replies:
    4
    Views:
    169
  4. Max
    Replies:
    5
    Views:
    262
    Thomas 'PointedEars' Lahn
    Apr 14, 2008
  5. rvelosoo
    Replies:
    1
    Views:
    391
    Bart Van der Donck
    Aug 13, 2008
Loading...

Share This Page