Hi i'm trying to use 2 sqlite tables to create a select menu.
I use the below code
t.executeSql('SELECT * FROM buildingflats WHERE buildingcode = ? ORDER BY flatname ASC',[buildingcode], function(t, resultflatcomment) {
var j,
lenflatcomments = resultflatcomment.rows.length,
rowflatcomments,
row;
if (lenflatcomments > 0 ) {
for (j = 0; j < lenflatcomments; j += 1) {
rowflatcomments = resultflatcomment.rows.item(j);
t.executeSql('SELECT DISTINCT flatdescription, flatname, buildingcode FROM bill WHERE buildingcode = ? AND flatdescription = ?',[buildingcode, rowflatcomments.flatname], function(t, resultflat) {
var len = resultflat.rows.length;
if (len > 0) {
row = resultflat.rows.item(0);
alert(row.flatdescription); // alerts correct data
alert(row.flatname); // alerts correct data
$('#opt2').append('<option value="' + row.flatname + '">' + row.flatdescription + '...' + row.flatname + '</option>');
} else {
alert(rowflatcomments.flatname); // alerts always the same
$('#opt2').append('<option value="' + rowflatcomments.flatname + '">' + rowflatcomments.flatname + '</option>');
}
});
}
$("#opt2").selectmenu('refresh');
}
});
but the select menu is empty.
Where am I wrong?
Aucun commentaire:
Enregistrer un commentaire