jquery - how to access such a data from the database table in javascript? -


the problem facing peculiar.the values want visible,when message server-web console. but,when give in loop,it shows me error of 05-22 18:58:23.203: i/web console(29392): jscallback error: typeerror: cannot read property 'value' of undefined @ file:///android_asset/www/cordova-2.1.0.js:3727. means query right.i have committed mistake in loop retrieving data.

i new phone gap , using javascript code.i have doubt , problem while executing it.i using sqlite database in project.

my table structure this

id  cid values  1   1   value1 2   1   value2 3   1   value3 4   1   value4 5   2   value1 6   2   value2 7   3   value1 8   3   value2 9   3   value3 

so want values of same cid,how should code it?

my query:

tx.executesql("select cid,value table cid="+cid_value, [], querysuccess, errorcb,cid_value); 

because,when tried following manner,

var details = results.rows.length; console.log("db test value:"+results.rows.item(cid_value).value); (var i=cid_value; i<details; i++) { cidinstance=results.rows.item(i).cid; var valueinstance=results.rows.item(i).value; document.getelementbyid("s"+i+"cause").innerhtml=valueinstance; console.log("cid= "+cidinstance +   "valueinstance= "+valueinstance); } 

then when i=cid_value(cid_value=1) targeting cid=1, have 4 values 3 values.but,if put i=0,then 4 values

when i=cid_value(cid_value=2) targeting cid=2,i following

01-01 05:45:38.687: i/web console(2425): jscallback: message server: sqliteplugintransaction.querycompletecallback('1104538538488000','1104538538491000', [{"value":"value1","cid":"2"},{"value":"value22","id":"6","cid":"2"}]); @ file:///android_asset/www/cordova-2.1.0.js:3726.

the problem is,i getting values when message server js callback. not loop

please,suggest me ways solve problem!.guide me find way out.

try this, should work (i haven't tested it, in case let me know):

cid_value = "1"; try{     tx.executesql("select cid , value table cid = ?;", [cid_value], success, failure); }catch(e){     console.log("error: "+e.message); } this.success = function(tx, results){     if(results.rows.length > 0){         for(var x = 0; x < results.rows.length; x++){             var cidinstance = results.rows.item(x).cid;             var valueinstance = results.rows.item(x).value;             console.log("cid = "+cidinstance + " | valueinstance = "+valueinstance);     }else{         console.log("results length = 0");     } }; this.failure = function(tx, error){     console.log("error: "+error.message) } 

i think problem related value initialize "i" ver in cycle. let start 0 every result of resultset, instead of subset of it.

hope helps


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -