I have a select_list that gets populated in runtime. I need to select a value based on the item index.
Eg.
self.myselectlist1.option(indexval).select
If the indexval I pass is 3, it should select the third item.
The above code errors out. Is there an alternate way?
Assuming that
myselectlist1is the name of a select list defined in an accessor, you want:Explanation:
myselectlist1_elementis used to get the select list element.optionsreturns an array of option elements for the select list.[0]returns the first item of the options arrayclickclicks the option to select it. There is noselectdefined for options (ie you will get a deprecation warning).