0 Replies Latest reply on Jun 1, 2009 6:51 AM by Granger451

    Retrieving Data from SQLite and make link with the ID of the retrieved data?

    Granger451

      Hello, first of all sorry if my english is bad as im from Mexico.

       

      I using HTML/Javascript/SQLite, and im having an issue while retrieving data from SQLite, all my querys work right, but when i try to select an Id, the Name, Firstname, and Lastname and only use the Name, Firstname and Lastname to print on screen and the Id to use as a link or OnClick query with the id more info from the name of the person..

       

      My SQLite query is the next one.

      var sql = "SELECT [sis_persona].[idPersona], [sis_persona].[Nombre], [sis_persona].[Paterno], [sis_persona].[Materno] FROM  [sis_persona] WHERE Nombre  LIKE '"+ nombre1+"%' AND Paterno LIKE '"+ paterno1+"%' AND Materno LIKE '"+ materno1+"%' ORDER BY [sis_persona].[Nombre], [sis_persona].[Paterno], [sis_persona].[Materno] LIMIT 20";

       

      And my ResultHandler is the next one:

       

          row = document.createElement("tr");
                      cell = document.createElement("th");
                      cell.innerText = "Nombre";
                      row.appendChild(cell)        
                      
                      
                      
                      cell = document.createElement("th");
                      cell.innerText = "Paterno";
                      row.appendChild(cell)        
                      
                      
                      
                      cell = document.createElement("th");
                      cell.innerText = "Materno";
                      row.appendChild(cell)        
                      tbl.appendChild(row);
      
                      var numRows = result.data.length;
                      for (var i = 0; i < numRows; i++)
                      {
                              
                          // iterate over the columns in the result row object
                          row = document.createElement("tr");
                          
                          for (col in result.data[i])
                          {
                  var ea = result.data[i]; 
                  cell = document.createElement("td");
                  var a  = document.createElement( 'a' );
                  a.setAttribute('HREF','#');
                  
                  
                  var txt = document.createTextNode( ea.Nombre );
                  a.appendChild( txt );
                  a.onclick = function() {querytest(ea.idPersona);};
                  row.appendChild( a );
                  row.appendChild(cell);
                  
                  
                  //
                  
                              cell = document.createElement("td");
                  var a  = document.createElement( 'a' );
                  a.setAttribute('HREF','#');
                  
                  
                  var txt = document.createTextNode( ea.Paterno );
                  a.appendChild( txt );
                  a.onclick = function() {querytest(ea.idPersona);};
                  row.appendChild( a );
                  row.appendChild(cell);
                  
              //
              
                          cell = document.createElement("td");
                  var a  = document.createElement( 'a' );
                  a.setAttribute('HREF','#');
                  
                  
                  var txt = document.createTextNode( ea.Materno );
                  a.appendChild( txt );
                  a.onclick = function() {querytest(ea.idPersona);};
                  row.appendChild( a );
                  row.appendChild(cell);
      
                  
                  
                               
                          }
                          
                          tbl.appendChild(row);
                      }
                  }
      
      
      
      

      And this is where i have the problem, it print three times and i dont know how to take print only the result and make a link with the id from the query.

       var ea = result.data[i]; 
                  cell = document.createElement("td");
                  var a  = document.createElement( 'a' );
                  a.setAttribute('HREF','#');
                  
                  
                  var txt = document.createTextNode( ea.Nombre );
                  a.appendChild( txt );
                  a.onclick = function() {querytest(ea.idPersona);};
                  row.appendChild( a );
                  row.appendChild(cell);

       

      Anyone have any ideas?

      Sorry again if my english is bad.

       

      Thanks in advance