Populating Select Lists

Discussion in 'Javascript' started by bryan.christina@gmail.com, Oct 27, 2006.

  1. Guest

    This semester in school, I'm taking an Introduction to JavaScript class
    online through my local community college. I'm having with an
    assignment that requires you to set up two select lists. When you
    select an option on the first list, it populates the second list with
    specific information unique to that selection (Our example is to select
    a state that would then populate a city list in the second). I can not
    find any information or example to help with the script I need to
    write, are there any suggestions?

    Bryan
     
    , Oct 27, 2006
    #1
    1. Advertising

  2. ASM Guest

    a écrit :
    > This semester in school, I'm taking an Introduction to JavaScript class
    > online through my local community college. I'm having with an
    > assignment that requires you to set up two select lists. When you
    > select an option on the first list, it populates the second list with
    > specific information unique to that selection (Our example is to select
    > a state that would then populate a city list in the second). I can not
    > find any information or example to help with the script I need to
    > write, are there any suggestions?


    You could try to find infos about new Option()

    new Option(value, text)


    Example with :
    - selct = selector (dropdown list)
    - list = array of items (fruits, materials, states, towns ...)

    function fillSelect(selct, list) {
    // to empty selector
    selct.length = 0;
    // new options
    for (var i=0; i<list.length; i++)
    {
    // new option : value and text
    var o = new Option(list, list)
    // grow selector adding new option
    selct[selct.length] = o;
    }
    }

    --
    ASM
     
    ASM, Oct 27, 2006
    #2
    1. Advertising

  3. wrote:
    >to set up two select lists. When you
    > select an option on the first list, it populates the second list with
    > specific information unique to that selection (Our example is to select
    > a state that would then populate a city list in the second). I can not
    > find any information or example to help with the script I need to
    > write, are there any suggestions?


    Where did you look? This homework question comes up so often that it's
    difficult to avoid references to it.

    Google: javascript +populate +"select box"
     
    Stephen Chalmers, Oct 28, 2006
    #3
    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. ben
    Replies:
    2
    Views:
    667
    Ben Arthur
    Mar 4, 2004
  2. Ben Arthur
    Replies:
    7
    Views:
    1,582
    BalajiSelvam
    Jan 3, 2011
  3. enstn85
    Replies:
    0
    Views:
    566
    enstn85
    Jun 20, 2006
  4. =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==

    List of lists of lists of lists...

    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==, May 8, 2006, in forum: Python
    Replies:
    5
    Views:
    444
    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==
    May 15, 2006
  5. Dan Thomas
    Replies:
    0
    Views:
    296
    Dan Thomas
    Feb 2, 2011
Loading...

Share This Page