title: HTML button call on javascript function not working with sqlite database
body: <p>HTML file: </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
  
          &lt;link rel="stylesheet" type="text/css" href="css/index.css"&gt;
          &lt;title&gt;SqliteSampleForm&lt;/title&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Sample Sqlite Database Form&lt;/h1&gt;
          &lt;p align="center"&gt;
  
              &lt;input type="text" id="name" placeholder="Enter First Name" name="firstname" /&gt;
              &lt;input type="text" id="name" placeholder="Enter Last Name" name="lastname" /&gt;
              &lt;input type="text" id="name" placeholder="Enter contact number" name="contactnumber" /&gt; &lt;br /&gt;&lt;br /&gt;
  
         &lt;button onclick="add()"&gt; submit &lt;/button&gt;   
  
          &lt;/p&gt;
  
  
          &lt;script type="text/javascript" src="cordova.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="scripts/platformOverrides.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="scripts/index.js"&gt;&lt;/script&gt;
  
  
      &lt;/body &gt;
  &lt;/html &gt;
  </code></pre>
  
  <p>Here's my index.js file:</p>
  
  <pre><code>(function () {
  "use strict";
  
  var db = null;
  
  document.addEventListener("deviceready", function () {
      db = window.sqlitePlugin.openDatabase({ name: "note.db", iosDatabaseLocation: 'default' });
      db.transaction(function (tx) {
          tx.executeSql("CREATE TABLE IF NOT EXISTS note (firstname text primary key, lastname text, contactnumber text)");
          alert("Database Table created");
      }, function (err) {
          alert("An error occured while initializing the app");
      });
  }, false);
  
  function add() {
      alert("Inside Add Function");
      var firstname = document.getElementByName("firstname").value;
      alert("Variabe firstname created: " + firstname);
      var lastname = document.getElementByName("lastname").value;
      var contactnumber = document.getElementsByName("contactnumber").value;
  
      if (firstname == "") {
          alert("Please enter first name");
          return;
      }
  
      if (lastname == "") {
          alert("Please enter last name");
          return;
      }
  
  
      if (contactnumber == "") {
          alert("Please enter contact number");
          return;
      }
  
      db.transaction(function (tx) {
          tx.executeSql("INSERT INTO note (firstname, lastname, contactnumber) VALUES (?,?,?)", [firstname, lastname, contactnumber], function (tx, res) {
              alert("Fields Added to the database");
          });
      }, function (err) {
          alert("An error occurred while saving the note");
      });
  }
  } )();
  </code></pre>
  
  <p>and the css file may not be needed so to avoid too much code i would avoid it.</p>
  
  <p>On clicking submit button, i should get the alert that i am inside add function as stated in the function definition, but i am not getting it.
  Where as i am getting the Database created alert in my application.
  Is this error due to sqlite database in my application?</p>