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
- function updateValue()
- {
- $('#contact').val($('#customer').val());
- }
- //update once the page has loaded too
- $(document).ready(function () {
- updateValue();
- });
- <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){
- $(".responsesign").html(response);
- //alert(response);
- }
- });
- });
- <?php
- include("connect.php");
- $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
- event.preventDefault();
- $.post( $("#myForm").attr("action"),
- $("#myForm :input").serializeArray(),
- function(info){ $("#result").html(info);
- return false; // at end
- });
- clearInput();
- });
-
- $("#myForm").submit( function() {
- return false;
- });
-
- function clearInput() {
- $("#myForm :input").each( function() {
- $(this).val('');
- });
- }