title: Retrieving value from database in Javascript
body: <p>I am new to mobile application development with PhoneGap. I have created a form to add and show name, address and phone number of a student in SQLite database. But the problem is I don't know to retrieve and display the values in the text boxes.</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
   &lt;head&gt;
      &lt;title&gt;Contact Example&lt;/title&gt;
  
      &lt;script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" charset="utf-8"&gt;
  
      document.addEventListener("deviceready", onDeviceReady, false);
  
      function onDeviceReady() {
          var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
          db.transaction(populateDB, errorCB, successCB);
      }
  
  
      function populateDB(tx) {
           tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (sname ,saddress ,sphone)');
      }
  
  
      function errorCB(tx, err) {
          alert("Error processing SQL: "+err);
      }
  
      // Transaction success callback
      //
      function successCB() {
          alert("success!");
      }
  
      function add(tx){
          var name=document.getElementById('n');
          var address=document.getElementById('a');
          var phone=document.getElementById('p');
          tx.executeSql('INSERT INTO DEMO (sname ,saddress ,sphone) VALUES ('"+name+"','"+address+"','"+phone+"')');
          //tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');    
  
      }
  
      function show(tx){
          var name=document.getElementById('n');
          tx.executeSql('SELECT * FROM DEMO WHERE (sname='"+name+"')');   
           document.f.n.value=name;
           document.f.a.value=//??;
           document.f.p.value=//??;
      }
  
      &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;form name="f" method="get" action=""&gt;
        Name  :&lt;input type="text" id="n" size="10"&gt;&lt;/input&gt;&lt;br&gt;
        Add &amp;nbsp;&amp;nbsp;&amp;nbsp; :&lt;input type="text" id="a" size="10"&gt;&lt;/input&gt;&lt;br&gt;
        Phone :&lt;input type="text" id="p" size="10"&gt;&lt;/input&gt;&lt;br&gt;
        &lt;input type="button" value="Add" onClick="add()"&gt;
        &lt;input type="button" value="Show" onClick="show()"&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>