i’m trying to create a categories list with Jquerymobile-html5 and websql/sqlite.
i post my code here to hope someone sees what i do wrong.
//load the cats to choose a cat
function loadCatOptions() {
var option_str='';
option_str += '<option value="0" data-placeholder="true">Choose categorie</option>';
//option_str += '<option value="0">Top/ParentiD</option>';
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM categories', [], function (tx, results) {
var len = results.rows.length, i;
for (i = 0; i < len; i++) {
var r = results.rows.item(i);
var catID = r.categories_id;
}
var count =0;
while (count < catID+1){
count;
tx.executeSql('SELECT c.parent_id, c.categories_id, cd.categories_name, c.categories_image FROM categories c, categories_description cd WHERE c.categories_id ='+ count +' AND cd.categories_id ='+ count +' and cd.language_id ="1" ORDER BY sort_order, cd.categories_name', [], function (tx, results) {
var len = results.rows.length, i;
for (i = 0; i < len; i++) {
var r2 = results.rows.item(i);
option_str += "<option value=" + r2['categories_id'] + ">" + r2['categories_name'] + "</option>";
console.log('categoriesname='+ r2['categories_name']);
$("#parent_id").html(option_str).selectmenu('refresh', true);
}
});
count++;
}
});
});
}
The consolelog shows all items by its name, so i’m sure that the database query is correct.
I might have spend days to someting what wasnt the problem at all.
if i take only the SELECT * query and call the selectmenu, i can see all categorie_id’s in the list (ofcourse replace categories_name by categories_id to got that to work).
So the problem now is with jquerymobile??????????????
It wont read the option_str += inside the second database query!
aaargg
Code above is updated with the fix.
From your question:
Problem fixed
old code: