select of select box will select multiple in another box

Discussion in 'Javascript' started by palmiere, Feb 9, 2004.

  1. palmiere

    palmiere Guest

    Im trying to do the following:

    I have 2 select boxes, both are pre populated with data. The first box
    is a single select box, the 2nd is a multiple select box. Depending on
    the 1st selection, I want to have multiple values in the second select
    box highlighted.

    ie
    box 1
    <select name=type>
    <option> warm colors
    <option> cool colors
    <option> shades of grey
    </select>

    box 2
    <select name=colors multiple>
    <option> red
    <option> orange
    <option> yellow
    <option> blue
    <option> green
    </select>

    If the user would select warm colors from box 1, red, orange and
    yellow would be highlighted for them. Any suggestions? Thanks.
    palmiere, Feb 9, 2004
    #1
    1. Advertising

  2. palmiere

    Erwin Moller Guest

    palmiere wrote:

    > Im trying to do the following:
    >
    > I have 2 select boxes, both are pre populated with data. The first box
    > is a single select box, the 2nd is a multiple select box. Depending on
    > the 1st selection, I want to have multiple values in the second select
    > box highlighted.
    >
    > ie
    > box 1
    > <select name=type>
    > <option> warm colors
    > <option> cool colors
    > <option> shades of grey
    > </select>
    >
    > box 2
    > <select name=colors multiple>
    > <option> red
    > <option> orange
    > <option> yellow
    > <option> blue
    > <option> green
    > </select>
    >
    > If the user would select warm colors from box 1, red, orange and
    > yellow would be highlighted for them. Any suggestions? Thanks.



    Hi, it is actually not difficult.
    Here is a piece of old examplecode to get you going:

    <html>
    <head>
    <title> titel </title>
    <script type="text/javascript">

    function setme(num)
    {
    document.forms.aform.fruit.selectedIndex = num;
    }

    </script>
    </head>

    <body>

    <form name="aform">

    <select name="fruit">
    <option value="bananas">bananas</option>
    <option value="kokos">kokos</option>
    <option value="apple">apple</option>
    </select>
    <input type=submit >
    </form>

    <p>
    <a href="javascript:setme(0);">set bananas</a><p>
    <a href="javascript:setme(1);">set kokos</a><p>
    <a href="javascript:setme(2);">set apple</a><p>
    </body>
    </html>



    Regards,
    Erwin Moller
    Erwin Moller, Feb 9, 2004
    #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. SirPoonga
    Replies:
    2
    Views:
    759
    Ben Strackany
    Jan 7, 2005
  2. Robin
    Replies:
    2
    Views:
    172
    Robin
    Apr 9, 2004
  3. dthmtlgod

    Fill Combo Box based on another Combo Box

    dthmtlgod, Nov 16, 2005, in forum: ASP General
    Replies:
    1
    Views:
    588
    Bob Barrows [MVP]
    Nov 16, 2005
  4. Ferd Berfel
    Replies:
    4
    Views:
    149
  5. SM
    Replies:
    2
    Views:
    365
Loading...

Share This Page