Q:

display data from sqlite database in html form(phonegap)

I have one html form in which all the fields have to filled from the data in my database. I tried using a javascript file and created one document.getElementbyID but it didn't worked.
getMultipleRows();

function getMultipleRows() {
    var db = window.sqlitePlugin.openDatabase({
        name: "drrem.db",
        location: 1
    });
    db.transaction(function (tx) {
        tx.executeSql('SELECT medicine_name FROM Medicine', [], function (tx, results) {
            var len = results.rows.length;
            if (len > 0) {
                for (var i = 0; i < len; i++) {
                    var a;
                    a[i] = results.rows.item(i)['medicine_name'];
                    document.getElementById("output").value = a[i];
                }
            }
        });
    });
}

Here is the html code in which I want the data to be displayed :
<input type="text" name="MedicineName" id="output"/>

A:

If you are sure there are data in your database, the here is how you should loop through it:
for (var i = 0; i < len; i++) {
    var a = results.rows.item(i)['medicine_name'];
    document.getElementById("output").value = a;
}

The problem with your original approach (var a; a[i] = results.rows.item(i)['medicine_name'];) is that when you declare a variable its value is undefined. So you can't assign a property i of undefined.

