RE: Dynamically populating a drop down list.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chandhseke
    New Member
    • Jun 2009
    • 92

    RE: Dynamically populating a drop down list.

    Hi Folks,

    I have designed a dynamic drop down list but having problems since it is not working as intended. Please help

    Code:
    <html>
    <head>
    <Script language="Javascript">
    
    var Select = new Array("-----");
    
    var test = (
    "Select",
    "ITEM 1",
    "ITEM 2",
    "ITEM 3",
    "ITEM 4");
    
    var test 1("Select",
    "Product 1",
    "Product 2",
    "Product 3",
    "Product 4");
    
    function swap(the_array_name)
    {
    var numbers_select = window.document.Formname.Product;
    var the_array = eval(the_array_name);
    setOptionText(window.document.Formname.Product,the_array);
    }
    
    function setOptionText(the_select, the_array)
    {
    var c;
    the_select.length=the_array.length;
    for (c=0; c < the_array.length; c++)
        {
        the_select.options[c].text = the_array[c];
        }
    }
    </script>
    <form name="Formname">
    <tr><td>
    <select name="item" onchange="swap(window.document.Formname.item.options[selectedIndex].value);">
    <option value="1">Test</option>
    <option value="2">Test 1</option>
    </select>
    
    <select name="Product">
    <option selected>Select</option>
    </select>
    </form>
    </html>
    <form name
    The above is the rough code like what i am trying to achieve. Please help me with this subject.

    Thanks in advance!!

    Chandhseke
    Last edited by Dormilich; Dec 12 '09, 12:10 PM. Reason: fixed [code] tags
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    how to define an Array.

    Comment

    Working...