cordova - phonegap insert query not happening -


in phonegap going insert values, calling onclick function query not inserting

function addnewrecord(tx) {     var rollno = $('#txtrollno').val();     var fname = $('#txtfirstname').val();     var lname = $('#txtlastname').val();     var mobno = $('#txtmobno').val();      var sql = 'insert test(rollno, firstname, lastname, mobileno) values ("'+rollno+'" , "'+fname+'" , "'+lname+'" , "'+mobno+'")';     alert(sql);     tx.executesql(sql, querysuccess, errorquery); } 

here in body onclick function in phonogap

<body >      <input id="txtrollno" type="text" placeholder="roll no">     <input id="txtfirstname" type="text" placeholder="firstname">      <input id="txtlastname" type="text" placeholder="last name">      <input id="txtmobno" type="text" placeholder="mob no">      <input type="button" value="add new" onclick="addnewrecord();">  </body> 

var mydb;   function createandinitdatabase() {  mydb = window.opendatabase("dbname", "0.1", "database app", 1024*1024); //create database parameters 1. database name 2.version number 3. description 4. size of database (in bytes) 1024 x 1024 = 1mb x 1024 = 1 gb      // create users table using sql database using transaction     mydb.transaction(function(t) {                                t.executesql("create table if not exists test (id integer primary key asc, rollno text,firstname text, lastname text, mobileno text)");     }); }  //insert function function insertdata(){        var rollno = $('#txtrollno').val();        var fname = $('#txtfirstname').val();        var lname =$('#txtlastname').val();        var mobno = $('#txtmobno').val();     if (mydb) {          mydb.transaction(function(t) {             t.executesql("insert test (rollno, firstname,lastname,mobileno) values (?,?,?,?)", [rollno,fname,lname,mobno],insertsuccesscallback,errorcallback);         });         function insertsuccesscallback() {           console.log('in insert success callback');         };         function errorcallback() {           console.log('in insert errorcallback');         };      } else {         console.log('db not available');     }  } 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -