INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

HTML5 and JQuery: SQL Query Output Display Help

HTML5 and JQuery: SQL Query Output Display Help

HTML5 and JQuery: SQL Query Output Display Help

(OP)
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: http://ofps.oreilly.com/titles/9780596805784/chapA... 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
);
}
);
}

RE: HTML5 and JQuery: SQL Query Output Display Help

(OP)
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) {
...

RE: HTML5 and JQuery: SQL Query Output Display Help

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

Cheers,
Dian

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close