Results 1 to 2 of 2

Thread: SQL Query to display one item on page.

  1. #1
    Join Date
    Feb 2012

    SQL Query to display one item on page.

    I have a form populated by SQLite/javascript. I have two pages, one that contains the form and displays a list of records by title that were added to the database. Each title has an edit link that populates the form with that items data. I have another page that I want to just display each record as static data when I click the title. I'm having trouble figuring out how to modify the code to just display one record when I do an onclick on the title. It works for the form, but not on the second page, which has no form. The second page lists the titles but displays all records when I click a title (which is to be expected since I just copied the query from the form page). Here's some code snippets from my second page:

    showList displays the titles, with a link to showRecords. I need showRecords to just show the record for the title clicked, not all records.

    function showList() {
    results.innerHTML = '';
    db.transaction(function(tx) {
    tx.executeSql(selectAllStatement, [], function(tx, result) {
    dataset = result.rows;
    for (var i = 0, item = null; i < dataset.length; i++) {
    * * item = dataset.item(i);
    * * results.innerHTML +=*
    * * '<a href="#" onclick="showRecords('+i+')">' + item['title'] + '</a>';
    function showRecords() {
    records.innerHTML = '';
    db.transaction(function(tx) {
    tx.executeSql(selectAllStatement, [], function(tx, record) *{
    dataset = record.rows;
    for (var i = 0, item = null; i < dataset.length; i++) {
    * * item = dataset.item(i);
    * * records.innerHTML +=*
    * * item['TArea'];
    } **
    I've searched for a solution but can't seem to figure out how to modify the code.
    Thanks for any help.

  2. #2
    Join Date
    Oct 2009
    Pass an id or anything to identify the link then add it as a filter
    Good Luck

    Santos Systems

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center