Phonegap javascrip how to check same details in sqlite

I have created a form to insert into sqlite db for a phonegap app.

How can I write to check the same activity name and give an alert to change the activity name? I have tried writing this but it does not work :

if(result.rows.item(i).FirstName ==$('aname').val()){
  alert("already exist.");
  return false;
}

function AddValueToDB(field1, field2, field3, field4, field5) {

  var x = document.forms["myForm"]["aname"].value;
  if (x == "") {
    alert("Activity name must be filled out");
    return false;
  }

  var z = document.forms["myForm"]["rname"].value;
  if (z == "") {
    alert("Reporter name must be filled out");
    return false;
  }

  var w = document.forms["myForm"]["date"].value;
  if (w == "") {
    alert("Date must be filled out");
    return false;
  }


  var field1 = document.getElementById(field1).value;
  var field2 = document.getElementById(field2).value;
  var field3 = document.getElementById(field3).value;
  var field4 = document.getElementById(field4).value;
  var field5 = document.getElementById(field5).value;
  var retVal = confirm("Correct information?" + '\n' + field1 + '\n' + field2 + '\n' + field3 + '\n' + field4 + '\n' + field5);



  if (retVal == true) {


    alert("successfully added");

    if (!window.openDatabase) {
      alert('Databases are not supported in this browser.');
      return;
    }

    // this is the section that actually inserts the values into the User table
    db.transaction(function(transaction) {
      transaction.executeSql('INSERT INTO User(FirstName, Location, aDate, Time, LastName) VALUES (?,?,?,?,?)', [$('#txFirstName').val(), $('#txLocation').val(), $('#txDate').val(), $('#txTime').val(), $('#txLastName').val()],
        nullHandler, errorHandler);
    });
<form name="myForm" action="" onsubmit="return AddValueToDB()" method="post">
  <p>Activity Name :</p>
  <input id="txFirstName" type="text" name="aname"> <br/>
  <p>Location :</p>
  <input id="txLocation" type="text" name="location"> <br/>
  <p>Date :
    <input type="date" id="txDate" name="date"> <br /><br /></p>
  <p>Time :
    <input type="time" id="txTime" name="time"> <br /><br /></p>
  <p>Reporter Name :</p>
  <input id="txLastName" type="text" name="rname"> <br /><br />
  <input type="button" value="Add" onClick="AddValueToDB('txFirstName', 'txLocation', 'txDate', 'txTime', 'txLastName')"> <br />

</form>
 Run code 

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.