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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Web and WebWorks Development

Reply
Trusted Contributor
KJake
Posts: 202
Registered: ‎11-21-2010
My Carrier: Virgin Mobile
Accepted Solution

Add Items to Select

I can execute a SQLite select statement to return results.  How do I loop through the results using javascript to add items to a <select> in the form?  I can getelementbyyid but how do I add itemsfrom the results?

 

Please use plain text.
Trusted Contributor
KJake
Posts: 202
Registered: ‎11-21-2010
My Carrier: Virgin Mobile

Re: Add Items to Select

Is this something that can be done?  Does it need to go between <select></select>?

Please use plain text.
Developer
jmace
Posts: 482
Registered: ‎10-24-2008
My Carrier: AT&T

Re: Add Items to Select

this site has the code to add an item to the select. I found it by searching google...

 

http://www.mredkj.com/tutorials/tutorial005.html

_________________________________________
www.jasonmace.com/blackberry
Please use plain text.
Developer
jmace
Posts: 482
Registered: ‎10-24-2008
My Carrier: AT&T

Re: Add Items to Select

actually, I just checked and found a snippet where I was doing what you needed. Check the code below

 

 

tx.executeSql("SELECT name,prop,api FROM Well",[],
   function processLoadingWells(tx, rs) {
      for (var i=0; i < rs.rows.length; i++) {
         var elOptNew = document.createElement('option');
	 elOptNew.text = rs.rows.item(i)['name'];
	 elOptNew.value = rs.rows.item(i)['prop'];
	 var elSel = document.getElementById('wellSelect');
	 elSel.add(elOptNew, null);
      }
   },
   function() { alert('failure');}
);

 

 

_________________________________________
www.jasonmace.com/blackberry
Please use plain text.
Trusted Contributor
KJake
Posts: 202
Registered: ‎11-21-2010
My Carrier: Virgin Mobile

Re: Add Items to Select

Excellent.  Thank you very much.

Please use plain text.