最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - dojo dynamically loading DropDownSelect widget - Stack Overflow

programmeradmin2浏览0评论

I have two DropDownSelect widgets added to my from what i need is to dynamically load the data in the second DropDownSelect widget as the first DropDownSelect widget changes how can i load the data in DropDownSelect widget programitacally.

Abdul khaliq

I have two DropDownSelect widgets added to my from what i need is to dynamically load the data in the second DropDownSelect widget as the first DropDownSelect widget changes how can i load the data in DropDownSelect widget programitacally.

Abdul khaliq

Share Improve this question asked Oct 29, 2009 at 16:09 Abdul KhaliqAbdul Khaliq 2,46312 gold badges40 silver badges65 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

I think you need something like this:

      dojo.connect(s1, 'onChange', function(value) {

      console.log(value); // selected in s1 value

      s2.addOption([{ 
        label: "new option1", value: 1
      },
      { 
        label: "new option2", value: 2
      },
      { 
        label: "new option3", value: 3
      }]);
    });

In this example above, when selected value of s1 changes, we load 3 new options into s2. You can pass only one option to addOption method instead of array:

    s2.addOption({ label: "new option1", value: 1 }

Probably, you also wish to clear s2 first:

    s2.options = [];

DropDownSelect has an "onChange" method which you can pass an anonymous function that builds the option list for the second select using something like addOption:

var s1 = new dojox.form.DropDownSelect();
var s2 = new dojox.form.DropDownSelect();
s1.onChange(function() {
  s2.addOption(new Option("text","value"));
});
发布评论

评论列表(0)

  1. 暂无评论