admin管理员组文章数量:1394207
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 badges2 Answers
Reset to default 5I 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"));
});
本文标签: javascriptdojo dynamically loading DropDownSelect widgetStack Overflow
版权声明:本文标题:javascript - dojo dynamically loading DropDownSelect widget - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744665100a2618480.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论