populating datalist

Hi! Experts, how to make this code that the data from Web Sql will populate to datalist? below is the code. Please help!

    function showme()
        db.transaction(function (tx)
    tx.executeSql('SELECT * FROM iTable2', [], function (tx, results) {
    var len = results.rows.length, i;
    msg = "<p>Found rows: " + len + "</p>";
    document.querySelector('#status').innerHTML +=  msg;
    for (i = 0; i < len; i++){
    msg = "<p><b>" + results.rows.item(i).firstName + "</b></p>";
    document.querySelector('#status').innerHTML +=  msg;
        }, null);

this is my datalist

<lable>Student names:</lable>
<input type="text" list="names" />
<datalist id="names">
    <option value="">
    <option value="">
Whing Dela CruzAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Could you provide example of output you get and how the end result should look like, please.
RobOwner (Aidellio)Commented:
You should be aware that WebSQL is no longer supported.  I can show you how to populate a datalist though if you still want to go down that track? Unless of course you are using the IndexedDB ? http://www.w3.org/TR/IndexedDB/
Whing Dela CruzAuthor Commented:
Hi Rob lurd, I'm still interested to do it. Please provide example. Thanks!
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

RobOwner (Aidellio)Commented:
Excluding SQL side of things, here is how you can populate a datalist with an array:  http://jsbin.com/didabiheci/1/edit?html,js,output

Note: I've used jQuery to simplify things and make the code cross browser compatible

$(function() {
  var names = ['Rob', 'John','Andrew','Jason','Steven'];
  for (i=0; i<names.length; i++) {
    $("#names").append("<option value='"+names[i]+"'/>");

Open in new window

Whing Dela CruzAuthor Commented:
Rob lurd, Please tell me how its possible that base on my post coded above, the data is coming from the database (Web Sql). Could you provide solution  for this. Please understand that I am a beginner for HTML5. Thanks!
RobOwner (Aidellio)Commented:
Please understand that I am a beginner for HTML5
given that's the case, WHY are you using web SQL?
RobOwner (Aidellio)Commented:
Please understand that I'm not trying to be difficult but rather steer you away from technologies that are not in use.  A database IMO has no place in this context within the browser.  It exposes your data and I would never use it.  Your data should be stored on your server and let it do the processing.  I know that spreading the processing of certain queries would reduce the load on a server but it may impact greatly on the client when it doesn't need to and may give unexpected results that you have no control over.
Whing Dela CruzAuthor Commented:
Just to accomplish what I started. Could you tell me Rob where should I start? If not Web Sql, What should be?
RobOwner (Aidellio)Commented:
I suggest starting where is your data stored.  Is this just an exercise for you to learn HTML5 or is it part of a bigger project?  It depends on what you're going to do with the data as well as where it comes from.
Assuming it comes from a database on a server, then using javascript (via ajax returning data in JSON format) to load the data and display it will serve you better than web sql.  I suggest learnging and using jQuery as it will simplify your javascript as well as make it cross-browser compatible (see my article on javascript frameworks, what are they)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Whing Dela CruzAuthor Commented:
Thanks a lot Rob, this is actually part of my practice. Thanks for your great suggestions...
RobOwner (Aidellio)Commented:
No problem but did you mean to grade it a B? If not can you request it to be changed
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.