Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML5 and JQuery: SQL Query Output Display Help

Status
Not open for further replies.

brainwarped

Programmer
Jun 11, 2012
2
US
Hi,

Please help me with the Javascript code below. The goal is to use JQuery and JQTouch to query a local database for all entries and then append them to the "#dates ul" element using the hidden entryTemplate HTML for structure. (Additional information can be found in the tutorial: and the next chapter.)

After extensive testing of the code, I believe the loop in the refreshEntries function is not running. I have tested the code in the desktop and mobile safari, and know that the database is recording entries, but the refreshEntries function is not displaying the entries. Please let me know if I have made a coding error.

The Javascript code that that performs the operation is below:

function refreshEntries() {
$('#dates ul li:gt(0)').remove();
db.transaction(
function(transaction) {
transaction.executeSql(
'SELECT * FROM entries ORDER BY id;',
function (transaction, result) {
for (var i=0; i < result.rows.length; i++) {
var row = result.rows.item(i);
var newEntryRow = $('#entryTemplate').clone();
newEntryRow.removeAttr('id');
newEntryRow.removeAttr('style');
newEntryRow.data('entryId', row.id);
newEntryRow.appendTo('#scans ul');
newEntryRow.find('.label').text(row.barcode1);
newEntryRow.find('.pack').text(row.packsAvailable);
newEntryRow.find('.delete').click(function() {
var clickedEntry = $(this).parent();
var clickedEntryId = clickedEntry.data('entryId');
deleteEntryById(clickedEntryId);
clickedEntry.slideUp();
});
}
},
errorHandler
);
}
);
}
 
So it appears the error is in this code. I just tried entering "[]" into the code, and the script works!

...
function(transaction) {
transaction.executeSql(
'SELECT * FROM entries ORDER BY id', [],
function (transaction, result) {
...

 
Nice to know, but for future posts, you will get more chance of answers in Javascript forum, this one is for Java.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top