nottoolate Posted June 24, 2011 Share Posted June 24, 2011 Hello, I'm trying to populate a form based on the users input in a specific text box (job number). But I'm having some trouble getting this to work properly. Currently, when I key in a job number, the fields that are to be populated display 'undefined', including my job number field. Also, taking a look at my job_setup.php, my variables are considered undefined and I'm not sure why. Here is my script: var url = "job_setup.php?param="; function getJobinfo() { var idValue = document.getElementById("job_number").value; var myRandom=parseInt(Math.random()*99999999); // cache buster http.open("GET", url + escape(idValue) + "&rand=" + myRandom, true); http.onreadystatechange = handleHttpResponse; http.send(null); } function handleHttpResponse() { if (http.readyState == 4) { results = http.responseText.split(","); document.getElementById('customer').value = results[0]; document.getElementById('bid_date').value = results[1]; document.getElementById('comp_date').value = results[2]; document.getElementById('job_number').value = results[3]; } } var http = getHTTPObject(); // We create the HTTP Object Here is the php file, job_setup.php: <?php if(strlen($param)>0){ $result = mysql_query("SELECT * FROM job WHERE job_id LIKE '$param%'"); if(mysql_num_rows($result)==1) { while($myrow = mysql_fetch_array($result)){ $customer = $myrow["cus_id"]; $bid_date = $myrow["job_stat_cd"]; $comp_date = $myrow["jt_cd"]; $job_id = $myrow["job_id"]; $textout .= $customer.",".$bid_date.",".$comp_date.",".$job_id; } } else { $textout=" , , ,".$param; } } echo $textout; ?> Quote Link to comment https://forums.phpfreaks.com/topic/240325-populate-form-through-php/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.