-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi there,
just try
<window title="Listbox" border="normal"> <listbox rows="1" mold="select" id="lb"> <listitem label="Inbox" id="Inbox" /> <listitem label="Received" id="Received" /> <listitem label="Draft" id="Draft" /> </listbox> <button label="Show selected item" onClick='Listitem li = lb.getSelectedItem(); alert( li == null? "No item selected" : String.valueOf( li ) );' /> </window>
According to my experience with ff it's impossible to get the 'Inbox' listitem selected unless I previously select 'Received' or 'Draft'. I'm not much sure as to what the philosofy of a dropdownlist should be, but perhaps the first item in the list should be the selected item by default.
With kind regards
César Varona
César,
One way to deal with this is just to set the selected index at create time. Simply change your <listbox> to look like this:
<listbox rows="1" mold="select" id="lb" onCreate="self.setSelectedIndex(0)">
Then, in your alert you can do something like this to get the actual label (e.g. Inbox):
alert(lb.getSelectedItem().getLabel());
Regards,
Todd
Asked: 2011-05-13 05:35:20 +0800
Seen: 302 times
Last updated: May 13 '11