Set value of a select in IE using YUI3
I have a select box and I need to both set the selected value and issue a change event with javascript.
In Firefox, the following works with no problem:
Y.one('#my_select_box').开发者_开发问答set('value', STEP_VALUES);
Y.one('#my_select_box').simulate('change');
No such luck in IE (IE7 in this case). The selected's value does not even change. I have tried using 'selectedIndex' instead of 'value' too.
Any ideas?
A reasonable answer is mySelect.query('option[value=foo]').set('selected', true);
, however according this ticket it looks like the set('value', value)
approach should work on the select tag itself, so I'm still unsure about that (I'm using YUI 3.1.1), so I'm still interested in any comments.
I didn't have success with the suggested answer, however I did have success with.
Y.one("#object").set("selectedIndex", 1);
Where 1 is the index to be selected.
精彩评论