Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-01-2012, 02:19 PM   PM User | #1
phisim
New to the CF scene

 
Join Date: Mar 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
phisim is an unknown quantity at this point
Unhappy Database Reference Error :/

hi im new and looking for a little help, writing a phonegap application using html and javascript with JQTouch library.
when i try to search a database it comes back with reference error ofr the 'txs' even though the database is being used perfectly fine with another function. Any help would be appreciated.


//init the JQTouch instance.
var jQT = new $.jQTouch();




$(document).ready(function(){
refreshData();
});

//set-up a variable named db for the web database.
var db;

//set-up database name
db = openDatabase('dpDatabase_v2', '1.0', 'Digital Plants Database', 2 * 1024 * 1024);

db.transaction(function (txs) {

txs.executeSql('CREATE TABLE IF NOT EXISTS plants (id unique, name TEXT, category TEXT, latin TEXT, large INTEGER, descr TEXT, img TEXT)');
txs.executeSql('DELETE FROM plants');

txs.executeSql('INSERT INTO plants (id, name, category, latin, large, descr, img) VALUES (?, ?, ?, ?, ?, ?, ?)', ['1', 'Lily', 'Flower', 'Lilium', '1', '<p>The range of lilies in the Old World extends across much of Europe, across most of Asia to Japan, south to the Nilgiri mountains in India, and south to the Philippines. In the New World they extend from southern Canada through much of the United States. They are commonly adapted to either woodland habitats, often montane, or sometimes to grassland habitats. A few can survive in marshland and epiphytes are known in southeast Asia (including L. arboricola). In general they prefer moderately acidic or lime-free soils.</p>','lilly_lrg.jpg']);
txs.executeSql('INSERT INTO plants (id, name, category, latin, large, descr, img) VALUES (?, ?, ?, ?, ?, ?, ?)', ['2', 'Oxeye Daisy', 'Flower', 'Leucanthemum vulgare', '1', '<p>A widespread flowering plant native to Europe and the temperate regions of Asia. It is one of a number of Asteraceae family plants to be called a daisy, and has the vernacular names common daisy, dog daisy, margarite, moon daisy, and ox-eye daisy.</p>','daisy_lrg.jpg']);
txs.executeSql('INSERT INTO plants (id, name, category, latin, large, descr, img) VALUES (?, ?, ?, ?, ?, ?, ?)', ['3', 'Tulip', 'Flower', 'Tulipa', '1', '<p>Most tulips produce only one flower per stem, but a few species bear multiple flowers on their scapes (e.g. Tulipa turkestanica). The showy, generally cup- or star-shaped tulip flower has three petals and three sepals, which are often termed tepals because they are nearly identical. These six tepals are often marked near the bases with darker colorings. Tulip flowers come in a wide variety of colors, except pure blue</p>','tulip_lrg.jpg']);
txs.executeSql('INSERT INTO plants (id, name, category, latin, large, descr, img) VALUES (?, ?, ?, ?, ?, ?, ?)', ['4', 'Hyacinth', 'Flower', 'Hyacinthus', '1', '<p>The Dutch, or Common Hyacinth of house and garden culture was so popular in the 18th century that over 2,000 cultivars were cultivated in the Netherlands, its chief commercial producer. This hyacinth has a single dense spike of fragrant flowers in shades of red, blue, white, orange, pink, violet, or yellow. A form of the common hyacinth is the less hardy and smaller blue- or white-petalled Roman hyacinth of florists. These flowers should have indirect sunlight and are to be moderately watered.</p>','hyacinth_lrg.jpg']);


});

function refreshData(){
//add the fields to the screen...
db.transaction(function (txs) {
txs.executeSql('SELECT * FROM plants ', [], function (txs, results) {
var len = results.rows.length, i;
for (i = 0; i < len; i++) {
var row = results.rows.item(i);
var newEntryRow = $('#plantTemplate').clone();
newEntryRow.removeAttr('id');
newEntryRow.removeAttr('style');
newEntryRow.data('entryId', row.id);
newEntryRow.appendTo('#plants ul');
newEntryRow.find('.label').text(row.name);
newEntryRow.find('.label').addClass(row.id);






}
});
});
}

$(function(){

$('#ss').tap(function(){

value = $("#search-text").val();
$('#searchResultsHere ul li:not(:first)').remove();
searchPlants(value);
});



function searchPlants(searchstring){

txs.executeSql('SELECT * FROM plants where name like "' + searchstring + '%"', [],
function (txs, results){
var len = results.rows.length, i;
var myitem = "";
for(i=0; i< len; i++){
var row = results.rows.item(i);
var newEntryRow = $('#searchFindings').clone();
newEntryRow.removeAttr('id');
newEntryRow.removeAttr('style');
newEntryRow.data('entryId', row.id);
newEntryRow.appendTo('#searchResultsHere ul');
newEntryRow.find('label').text(row.name);
newEntryRow.find('label').addClass(row.id);
}
if (len==0){
alert('nothing found');
}


});
}
phisim is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:28 AM.


Advertisement
Log in to turn off these ads.