Reputation: 2453
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
Upvotes: 3
Views: 4540
Reputation: 1411
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 = [];
Upvotes: 5
Reputation: 12966
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"));
});
Upvotes: 1