04-25-2011 05:12 PM
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?
Solved! Go to Solution.
04-28-2011 06:55 PM
Is this something that can be done? Does it need to go between <select></select>?
04-29-2011 01:34 PM
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
04-29-2011 01:38 PM
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');}
);
04-29-2011 01:58 PM
Excellent. Thank you very much.