Filling up combo by selecting values of multiple combo in Javascript

Discussion in 'JavaScript' started by computerzworld, Dec 16, 2008.

  1. #1
    Hello All,
    I want to fill up the combo by selecting values and text of multiple combo in Javascript.


    I am having one multiple selection box which contains the values coming from database. And I want to fill up the second combo(single selection combo) from that because what is the exact requirement is that user can select multiple options & from that one will be default option. So, that what I require exactly is to select multiple combo & fill out its values in second one. And if user unselects some values the values in the second combo will also be removed.

    How can I do this? Please help me. Thanks in advance.
     
    computerzworld, Dec 16, 2008 IP
  2. rene7705

    rene7705 Peon

    Messages:
    233
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    with a bit of javascript you can do that.

    you make a function called updateComboBox() which will update the combobox with the selected values.
    that function gets called from the onchange= for the multi-select box.

    you have a second function called comboBoxItemSelected(), which -for now- only updates a global var with the selected value in the combobox. it gets called in the onchange= of the combobox.

    updateComboBox will empty out the combobox, fill in the new selected values, and select the one that is equal to the global var mentioned in the previous paragraph..

    As for the exact syntax to use, i'd have to look it up, but you can do that yourself too;
    http://www.w3schools.com/TAGS/tag_Select.asp
     
    rene7705, Dec 21, 2008 IP