0 Replies Latest reply on Nov 10, 2017 2:45 AM by thirdrail

    Target specific row in SQLite (Cordova)

    thirdrail

      Please help. I'm looping through rows and display the items in a list. When I click a row, I need to get the row name. I think I need to get the rowid but I'm not sure how. All the below code is getting is the last row name.

       

      db.transaction(function(tx) {
        tx
      .executeSql('CREATE TABLE IF NOT EXISTS client (name TEXT)');
        tx
      .executeSql('SELECT * FROM client', [], function (tx, results) {
        
      for(var x = 0; x < results.rows.length; x++) {
        var
      $single = results.rows.item(x);
        var
      $singleName = $single.name;
        var
      $wrapper = $('<div class="client-row" />').appendTo('.client-list');
        
      $wrapper.append ('<div class="client-name">' + $singleName + '</div>');

        
      $(document).on("click", ".client-row", function(){
        
      $(".indiv-client").show();
        
      $(".current-client").text($singleName);
        
      });
        
      }
        
      });
      });