且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

仅第二次进行onselect工作

更新时间:2023-12-06 08:16:52

将您的change_on_select更改为以下内容:

Change your change_on_select to as below:

工作示例@ http://jsfiddle.net/3dCyw/1/

function change_second_select(){
var sel1 = document.getElementById('select1')
  , sel2 = document.getElementById('select2');
  var os = select2data[sel1.value]; // Get the options required by select1.
  if (os) {
    sel2.options.length = 0; // Clear the options for select2.
    for (var i=0; i<os.length; i++) {
      var o = new Option(os[i][0], os[i][1]);
      try { // Add each option, allowing for browser differences.
        sel2.add(o);
      } catch (ex) {
        sel2.add(o, null);
      }
    }
    sel2.selectedIndex = 0;

  }
  return true;
}