views:

13

answers:

1

Hi,

So I know how to store and retrieve data in a local database (Chrome). My function to retrieve data is

function SelectHandler(transaction, results) {

    for (var i = 0; i < results.rows.length; i++) {

        var row = results.rows.item(i);
        var customer = new Object();

     customer.id = row['id'];
        customer.fname = row['fname'];
        customer.lname = row['lname'];

    }

}

I know how to assign the values from the function above to textboxes/labels etc but how do I create options in a dropdownlist with for example text first name and value id? I want to be able to select a name in the dropdown and then populate a textbox with the related last name (simplified example).

Thanks in advance.

A: 
for (var i = 0; i < results.rows.length; i++) {
    var row = results.rows.item(i);
    var newFeature = new Object();
    newFeature.id = row['id'];
    newFeature.name = row['name']

    $('#ddlPatients').append(
        $('<option></option>').val(newFeature.id).html(newFeature.name)
     );
}
Morgan