webuijsf:dropDown Set Selected value via Javascript

View: New views
2 Messages — Rating Filter:   Alert me  

webuijsf:dropDown Set Selected value via Javascript

by samotage :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have a question that someone may be able to help.  Good old http://webdev2.sun.com/woodstock-tlddocs/webuijsf/ doesn't seem to be working to help the doco on this woodstock drop down component so I am in the lurch a little :(

What I am trying to do is this:

Use a Javascript driven event to invoke a pop up to perform a value search.  The relevant value and it's corresponding data selected from the search help is then returned to the opening page via a Javascript method.

Now, I can set the fields on the page from the returned data, but...  one of the return fields is a drop down, and I am looking for some methods to call on the dorp down page element to set the selected value.

Now because this is not a normal HTML drop down, the classic solution don't work...  hence I am wondering if someone can help?

Many thanks,
Sam.

Re: webuijsf:dropDown Set Selected value via Javascript

by samotage :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


samotage banged his head against a hard surface and came up with an answer that may help some other poor stuck developer...

function setVal( state)
{
        stateElement=document.getElementById(form1:stateDD_list);
        var len = stateElement.length;
                                       
        for (var idx=0;idx < len;idx++)
        {
                if (state==stateElement.options[idx].value)
                {
                        stateElement.selectedIndex=idx;
                        stateElement.options[idx].selected=true;
                        break;
                }
        }
}

Sam.



LightInTheBox - Buy quality products at wholesale price