I'm checking out the sqlite and html5 using Javascript, heres the code I'm using to create, my DB, create my table and insert values from 3 text boxes that I have
function Add2DB()
{
var Tname = document.getElementById('txtName').value;
var Tprice = document.getElementById('txtPrice').value;
var Tqty = document.getElementById('txtQTY').value;
db.transaction(function (tx){
tx.executeSql('INSERT INTO foo (name,price,qty) VALUES(?,?,?)',[Tname,Tprice,qty]);
tx.executeSql('SELECT * FROM foo', [], function (tx, results){
var len = results.rows.length;
//For statements not allowed, just bring back first item in db
alert(results.rows.item(0).text)
});
});
}
The problem I'm having is that whenever I iterate through this, It just says Object object
. I think it is a Javascript problem I'm having, I'm not certain though
tx.executeSql('INSERT INTO foo (name,price,qty) VALUES(?,?,?)',[Tname,Tprice,qty]);
This line might not be right eit开发者_开发知识库her and may not be actually inserting the mapped values right. Can someone please shed some light on this. Any help, or ideas would help me greatly. Thank you.
Rather than an alert, if you use console.log (requiring Firefox with Firebug or a webkit-based browser) you can easily see more detail in what you're working with.
Try console.log("Results row: %o", results.rows.item(0).text);
If it is an object you'll be able to see into the object and better understand what it is. You'll need to look in the javascript console in those browsers.
精彩评论