title: openDatabase Hello World - 2
body: <p>This is a continuation from a <a href="https://stackoverflow.com/questions/2519844/opendatabase-hello-world">previous</a> stackoverflow question.
  I've renamed some variables so that I can tell what are keywords and what are names that I can control.</p>
  
  <p>Q: Why is the deleteRow function not working?</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;html5 openDatabase Hello World&lt;/title&gt;
  &lt;script src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  google.load("jquery", "1");
  google.setOnLoadCallback(OnLoadCallback);
  
  function OnLoadCallback() {
      var dbo;
      dbo = openDatabase('HelloWorld');
  
      dbo.transaction(
        function(T1) {
            T1.executeSql(
                'CREATE TABLE IF NOT EXISTS myTable ' +
                '  (myTableID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, ' +
                '   Field1 TEXT NOT NULL );'
            );
        }
      );
  
      dbo.transaction(function(T2) {
          T2.executeSql('SELECT * FROM myTable',[], function (T6, result) {
            for (var i=0; i &lt; result.rows.length; i++) {
              var row = result.rows.item(i);
              $('#savedData').append('&lt;li id="'+row.myTableID+'"&gt;' + row.Field1  + '&lt;/li&gt;');
            }
          }, errorHandler);
      });
  
      $('form').submit(function() {
        var xxx = $('#xxx').val();
        dbo.transaction(
            function(T3) {
                T3.executeSql(
                'INSERT INTO myTable (Field1) VALUES (?);', [xxx], function(){
                      $('#savedData').append('&lt;li id="ThisisWhereIneedHELP"&gt;' + xxx  + '&lt;/li&gt;');
                       $('#xxx').val('');
                },
                errorHandler
                );
            }
        );
        return false;
      });
      $('#savedData &gt; li').live('click', function (){
          deleteRow(this.id); 
          $(this).remove();
      });
  }
  
  function deleteRow(myTableID) {
      alert('trying to delete');
      dbo.transaction(function(T4) {
          T4.executeSql('DELETE FROM myTable WHERE myTableID = ?', [myTableID], function(){
              alert('Deleted!');
          }, errorHandler);
      });
  }
  
  function errorHandler(T5, error) {
      alert('Oops. Error was '+error.message+' (Code '+error.code+')');
      // T5.executeSql('INSERT INTO errors (code, message) VALUES (?, ?);',
      // [error.code, error.message]);
      return false;
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form method="post"&gt;
      &lt;input name="xxx" id="xxx" /&gt;
      &lt;p&gt;
      &lt;input type="submit" name="OK" /&gt;
      &lt;/p&gt;
      &lt;ul id="savedData"&gt;
      &lt;/ul&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>