Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I think this forum rocks it has saved my bacon many many times..."

Geography

Where in the world do Tek-Tips members come from?

HTML5 and JQuery: SQL Query Output Display Help

brainwarped (Programmer)
12 Jun 12 11:35
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
);
}
);
}
brainwarped (Programmer)
12 Jun 12 12:23
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) {
...

Diancecht (Programmer)
13 Jun 12 4:25
Nice to know, but for future posts, you will get more chance of answers in Javascript forum, this one is for Java.

Cheers,
Dian

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!

Back To Forum

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