views:

286

answers:

2

Using javascript, I am trying to change the selection of the listbox item like this:

 function selectFirstActiveListItem(oListBox)
    {
         for (var i = 0; i < oListBox.options.length; i++)
         {
            oListBox.selectedIndex = i;                

            var szStatus = GetDomboBoxItemAttribute("Status", m_pdocConnectType.getXMLDOM(), oListBox);

            if ("Enabled" == szStatus)
                return;
         }
         oListBox.selectedIndex = 0;
    }

Though the index correctly changes at the background, but it is not reflected on the UI. The listbox still shows the old selection.

What's going wrong?

+2  A: 

try this instead:

oListBox.options[i].selected = true;
spudly
A: 

Oops! That was working and showing the correct result. My take on the behaviour was incorrect there. Thanks for the answer and sorry for the trouble.

Manav Sharma