Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Posts: 189
Registered: ‎08-13-2008
My Device: Not Specified

Drop Down elements in Bold

Hello

I have a problem using drop downs and javascript in the Bold.

I have created a simple html page which replicates the problem -

Drop Down Test

The 1st problem seems to be that the options of the drop down are read as elements in the form.

The 2nd problem which is stopping me creating a work around is that when I try to access the fieldname of these option elements I get an error raised??

This is causing me a headache as a client has just moved to the Bold and has started experiencing this problem.

I have tried the test page on all other simulator versions and it only errors in simulator versions >4.6

If anyone has any ideas about this I would greatly appreciate the help as it's causing problems here!


Thanks
 
Andrew
Developer
Posts: 189
Registered: ‎08-13-2008
My Device: Not Specified

Re: Drop Down elements in Bold

I have managed to find a work around - for reference:

 

check the type of the element before accessing the name property of an element in the form.

 

e.g.

function test()
        {
             try
            {       
                for(i=0; i<document['frm_test2'].elements.length; i++)
                {
                    fieldtype = document['frm_test2'].elements[i].type;
                    if (fieldtype == 'select-one')
                    {
                        alert('ok');
                    }
                 }
            }
            catch(err)
            {
                alert('error-'+err.description);
            }           
        }

 

 

I have read up on the latest javascript functionality in the documention and there is a HTMLOptionElement, I am assuming this is being included in the elements?

 

Can anyone clarify this.

 

thanks

 

Andrew
Highlighted
Retired
Posts: 76
Registered: ‎07-11-2008
My Device: Z10
My Carrier: SingTel

Re: Drop Down elements in Bold

That's correct.

 

You can also access the options by invoking document.form_name.list_name.options.item(i) and then access the relevant property (example .text). For more details, refer to the JavaScript Reference Guide for 4.6:

http://na.blackberry.com/eng/support/docs/subcategories/?userType=21&category=BlackBerry+Browser

Sarim
BlackBerry Development Advisor
www.BlackBerryDeveloper.com