2010-01-30 86 views

回答

1

數據來自哪裏?我不確定你最需要哪個部分的答案:

  1. 您需要將事件處理程序添加到第一個下拉列表的OnChange事件中。
  2. 在事件處理程序中,您需要從某處獲取數據(AJAX?)
  3. 然後您需要獲取新數據和add it to the second dropdown

這裏基本上是你做什麼:

document.getElementById('dropdown1').onchange = yourFunction; 

function yourFunction() { 
    //Here is where you need to get the data 

    //Then you need to add them to the other dropdown like this: 
    var dropdown2 = document.getElementById('dropdown2'); 

    var optn = document.createElement("OPTION"); 
    optn.text = text; 
    optn.value = value; 
    dropdown2.options.add(optn); 
}