0

Hello,

I'm trying to populate a form with information from a database based on a textbox entry.
However, when I begin to key in the textbox I receive "undefined" in each textbox throughout the form.
Can someone take a look at my code for any errors? It also appears that my $_GET is not working properly.

var url = "job_setup.php";
			function getjobinfo() {
			var jobid = document.getElementById("job_number").value;
			var queryString = "?jobid=" + jobid;
			http.open("GET", url + queryString, true);
			http.onreadystatechange = handleHttpResponse;
			http.send(null);
			}

			function handleHttpResponse() {
			if (http.readyState == 4) {
			 results = http.responseText.split(",");
			   document.getElementById('discount_pcnt').value = results[0];
			   document.getElementById('client_discount').value = results[1];
			   document.getElementById('davis_bacon').value = results[2];
			   document.getElementById('bond').value = results[3];
			   document.getElementById('retainage_pcnt').value = results[4];
			   document.getElementById('retainage').value = results[5];
			   document.getElementById('repro_pcnt').value = results[6];
			   document.getElementById('repro').value = results[7];
			   document.getElementById('act_tax_exempt').value = results[8];
			   document.getElementById('po_con').value = results[9];
			   document.getElementById('con_date').value = results[10];
			   document.getElementById('con_amt').value = results[11];
			   document.getElementById('fax_num').value = results[12];
			   document.getElementById('send_inv').value = results[13];
			   document.getElementById('con_email').value = results[14];
			   document.getElementById('zip2').value = results[15];
			   document.getElementById('city2').value = results[16];
			   document.getElementById('street2').value = results[17];
			   document.getElementById('act_job_type').value = results[18];
			   document.getElementById('act_job_status').value = results[19];
			   document.getElementById('tax').value = results[20];
			   document.getElementById('pc').value = results[21];
			   document.getElementById('pa').value = results[22];
			   document.getElementById('pm').value = results[23];
			   document.getElementById('opp_owner').value = results[24];
			   document.getElementById('prop_author').value = results[25];
			   document.getElementById('dm').value = results[26];
			   document.getElementById('client_phone').value = results[27];
			   document.getElementById('client_pm').value = results[28];
			   document.getElementById('zip').value = results[29];
			   document.getElementById('city').value = results[30];
			   document.getElementById('street').value = results[31];
			   document.getElementById('prop_rate').value = results[32];
			   document.getElementById('prob').value = results[33];
			   document.getElementById('customer').value = results[34];
			   document.getElementById('bid_date').value = results[35];
			   document.getElementById('comp_date').value = results[36];
			   document.getElementById('job_number').value = results[37];
			 }
			}
			 function getHTTPObject() {
			        var xmlhttp;
			        /*@cc_on
			         @if (@_jscript_version >= 5)
			          try {
			              xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			              } catch (e) {
			              try {
			                  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			                  } catch (E) {
			                  xmlhttp = false;
			                  }
			              } 
			         @else
			          xmlhttp = false;
			         @end @*/
			        if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			         try {
			           xmlhttp = new XMLHttpRequest();
			           } catch (e) {
			           xmlhttp = false;
			           }
			          }
			          return xmlhttp;
			        }
			var http = getHTTPObject(); // We create the HTTP Object

and here is my php:

//Setup
require("../setup.php");
//Include files
include $GLOBALS['include_path']."support.functions.php";

$_GET['jobid'] = $job_id;

if(strlen($job_id)>0){
	$result = get_job_setup_info($job_id);
	foreach ($result as $myrow){
				//Client Billing Information
				$client_dscnt = $myrow['client_dscnt'];
				$discount = $myrow['discount'];
				$davis_bacon = $myrow['davis_bacon'];
				$bond_cd = $myrow['bonded'];
				$tax = $myrow['tax'];
				$repro = $myrow['repro'];
				$repro_pcnt = $myrow['repro_pcnt'];
				$retainage = $myrow['retain'];
				$retainage_pcnt = $myrow['retain_pcnt'];
				$invoice = $myrow['invoice'];
				$email = $myrow['email'];
				$fax = $myrow['fax_num'];
				$street2 = $myrow['street_2'];
				$city2 = $myrow['city_2'];
				$zipcode2 = $myrow['zipcode_2'];
	   			$contract_id = $myrow['contract_id'];
	   			$contract_amt = $myrow['contract_amt'];
	   			$contract_date = $myrow['contract_date'];
	   			$act_job_status = $myrow['job_status'];
	   			$act_job_type = $myrow['job_type'];
	   			
	   			//Client Information
				$opp_owner = $myrow['opp_owner'];
				$dm_id = $myrow['salesperson'];
				$prop_author = $myrow['prop_author'];
	   			$pm_id = $myrow['project_manager'];
	   			$pa_id = $myrow['project_admin'];
	   			$pc_id = $myrow['project_controller'];
	   			$tax_id = $myrow['tax_local'];
				$street = $myrow['street'];
				$city = $myrow['city'];
				$zipcode = $myrow['zipcode'];
	   			$client_pm = $myrow['client_pm'];
	   			$client_num = $myrow['client_num'];
				
	   			//Job Information
	   			$job_status = $myrow['job_stat_cd'];
	   			$job_type = $myrow['jt_cd'];
				$rate = $myrow['rate'];
				$prob = $myrow['prob'];
				$cus_id = $myrow['CUS_NAME'];
	   			$bid_date = $myrow['job_stat_cd'];
	   			$comp_date = $myrow['jt_cd'];
	  			$job_id = $myrow['JOB_ID'];
	   			
	  			$textout .= $client_dscnt.",".$discount.",".$davis_bacon.",".$bond_cd.",".$tax.",".$repro.",".$repro_pcnt.",".$retainage.",".$retainage_pcnt.",".$invoice.",".$email.",
	  			".$fax.",".$street2.",".$city2.",".$zipcode2.",".$contract_id.",".$contract_amt.",".$contract_date.",".$act_job_status.",".$act_job_type.",".$opp_owner.",".$dm_id.",".$prop_author.",
	  			".$pm_id.",".$pa_id.",".$pc_id.",".$tax_id.",".$street.",".$city.",".$zipcode.",".$client_pm.",".$client_num.",".$job_status.",".$job_type.",".$rate.",".$prob.",".$cus_id.",".$bid_date.",".$comp_date.",".$job_id;
			}
}
	echo $textout;

Thanks!

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by superbass
0

Assuming the php delivers what is expected, try http.responseHTML instead of http.responseText , ie.:

results = http.responseHTML.split(",");

By the way, you could avoid the cumbersome string-building in php by making $textout an array, pushing the data elements onto it in turn, then echoing implode(",", $textout); . This avoids the need for 37 individual variables, which exist only to build the output string. See implode.

You can get even smarter with json encoding.

Airshow

Edited by Airshow: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.