Total nubby with jquery I am having a problem with val() sending data to a form

Total nubby with jquery I am having a problem with val() sending data to a form


I am having a problem with this script .It adds the data to the html contact field below according to what is selected from the customer field. But when I save the data it saves what is in the contact field in the customer field also. How can I stop this from happening



  1. function updateValue()
  2. {
  3.     $('#contact').val($('#customer').val());
  4. }
  5. //update once the page has loaded too
  6. $(document).ready(function () {
  7.     updateValue();
  8. });


  1. <select name="customer"id="customer" class="responsetext1" onchange="updateValue();" >

  2. <input name="contact"  id="contact">

The falling script are how the drop down gets its data for the customer field




  1. $( document ).ready(function() 
  2. {
  3. $.ajax({    //create an ajax request to load_page.php
  4.         type: "GET",
  5.         url: "signing.php",
  6.         dataType: "html",   //expect html to be returned
  7.         success: function(response){                    
  8.             $(".responsesign").html(response); 
  9.             //alert(response);
  10.         }
  11.     });
  12. });

  1. <?php
  2. include("connect.php");
  3. $id = $_SESSION['profile']['id'];
  4. echo "<option value=''>SELECT A SIGNING</option>";
  5. foreach($db->query("SELECT * FROM signings WHERE pid = '$id' AND done = 0") as $row) {
  6.  
  7.    echo "<option value=" . $row['id'] . ">" .$row['ordern']. "   " .$row['lname'] . "</option>";
  8.  }






  1. This is the ajax script that sends the data to the php script to save the data from the form



  2. // JavaScript Document
  3. $("#sub").click( function(event) {
  4. //stop the click event from bubbling
  5.  event.preventDefault();
  6.  $.post( $("#myForm").attr("action"), 
  7.          $("#myForm :input").serializeArray(), 
  8.       function(info){ $("#result").html(info);
  9.  return false; // at end  
  10.    });
  11.  clearInput();
  12. });
  13.  
  14. $("#myForm").submit( function() {
  15.   return false;
  16. });
  17.  
  18. function clearInput() {
  19. $("#myForm :input").each( function() {
  20.    $(this).val('');
  21. });
  22. }