Q: why is my javascript not passing the values and giving no error messages I am using the following three bits of code. When i run the form using action="editName.php" it works fine, however when i try to fun the javascript it does not work. Can anyone see why it is not working? 
below is my form
   <form id="dataForm" method="GET">
      <h2 id="formheader"> Update Name</h2>
        <div>
          <label>Product Name:</label>
          <input class="inputForm" id="orginalName" type="text" name="Name">
        </div>
        <div>
          <label>New Name:</label>
          <input class="inputForm" id="newName" type="text" name="newName">
        </div>
        <div id="theSubmit">
          <button id="editButton">Submit</button>
        </div>
      </form>

below is my sql
if ($Name !="" && $newName !=""){ 
     $sql = "UPDATE PRODUCTS SET P_NAME = '$newName' WHERE P_Name = '$Name'";
     $conn->exec($sql);

below is my javascript
function updateProduct(){
  var xmlhttp = new XMLHttpRequest();
  var productName = document.getElementById("originalName").value;
  var newName = document.getElementById("newName").value;
  if(productName != "" && newName != ""){
    var url = "editName.php?Name=" + productName + "&newName=" + newName;

    xmlhttp.open("GET", url, false);
    xmlhttp.send();
     }
}
submitButton = document.getElementById("editButton");
submitButton.addEventListener("click", updateProduct);


A: Your input id = orginalName, but you looking for originalName
And please, read about SQL-injections

A: Use $.post because this is a one line code so it is so easy
like
$.post('url',{var1:'value1',var2:'value2'},function(data){
alert(data);
});

