Jump to content

populate form through php


nottoolate

Recommended Posts

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; ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.