How to write a program on Javascript

timer Asked: Feb 28th, 2014

Question description

I have two codes below to test what I am trying to do. Every thing in the code is working except I can not get it to fill the input field at the bottom of the first script. After two day of tinkering I cant figure out way. When I run the code and look at the results in Developer tools and it show the data being created but it will not place it in the input field . I have a demo set up if you need to look at it. I am still learning jquery and it is driving me crazy



    <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>

    <script type="text/javascript" src="js/jquery-ui-1.10.4.custom.min.js"></script>

   <script type="text/javascript">


    $(document).ready(function () {

    $("#customer").change(function () {

        var cid = $("#customer").val();


            type: "POST",

            url: "contact.php",

            data: "cid=" + cid,

            success: function (data) {

                var options = [];

                //$.each(data[cid - 1], function () {

                $.each(data, function () {

                    options.push('<option value="' + + '">' + + '</option>');











    <select name="customer" id="customer">

      <option>-Select a Customer-</option>




    $id = $_SESSION['profile']['id']; 

   foreach($db->query("SELECT * FROM customers WHERE pid = '$id'") as $row) {

        echo "<option value=" . $row['id'] . ">" . $row['name'] . "</option>";





<input type="text" value="" id="contact"/>





$cid = $_POST["cid"];

foreach($db->query("SELECT contact FROM customers WHERE id = '$cid'") as $row) {


 echo $row['contact'];


Studypool has helped 1,244,100 students
flag Report DMCA
Similar Questions
Hot Questions
Related Tags

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