Using val() in jquery to lookup data from a input box according to what's is selected from

Feb 21st, 2014
Price: $20 USD

Question description

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.

All the scripts below worked just fine until I added the first one below

This is the jquery script I am using

function updateValue()
//update once the page has loaded too
$(document).ready(function () {

Here is the two html fields that are being used

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

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

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

$( document ).ready(function()
$.ajax({  //create an ajax request to load_page.php
  type: "GET",
  url: "signing.php",
  dataType: "html",  //expect html to be returned
  success: function(response){   

$id = $_SESSION['profile']['id'];
echo "<option value=''>SELECT A SIGNING</option>";
foreach($db->query("SELECT * FROM signings WHERE pid = '$id' AND done = 0") as $row) {
  echo "<option value=" . $row['id'] . ">" .$row['ordern']. "  " .$row['lname'] . "</option>";

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

// JavaScript Document
$("#sub").click( function(event) {
 //stop the click event from bubbling
 $.post( $("#myForm").attr("action"),
  $("#myForm :input").serializeArray(),
  function(info){ $("#result").html(info);
  return false; // at end  
$("#myForm").submit( function() {
  return false;
function clearInput() {
 $("#myForm :input").each( function() {

Tutor Answer

(Top Tutor) Daniel C.
School: Boston College

Studypool has helped 1,244,100 students

Review from our student for this Answer

Feb 21st, 2014
"<3 it, thanks for saving me time. "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1825 tutors are online

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors