0 Replies - 397 Views - Last Post: 24 March 2010 - 12:23 AM

#1 fdhidha  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-March 10

unable to display data read by ajax

Posted 24 March 2010 - 12:23 AM

Hi,
Am unable to display company_name which is supposed to be passed by the ajax function


<?php
   include("config.php");
   
   $sqlselect="select *from glclass";
   $processselect= mysql_query($sqlselect) or die(mysql_error());
   
   $sqlselect="select *from glbranch";
   $processselectbr= mysql_query($sqlselect) or die(mysql_error());

   $sqlselect="select *from laclnt where client_type='C'";
   $processselectclt= mysql_query($sqlselect) or die(mysql_error());
   
   $sqlselect="select *from agmaster";
   $processselectagnam= mysql_query($sqlselect) or die(mysql_error());


   
   if($_POST)
   {
	 $sqlinsert="insert into glscheme(policy_no,uw_year,class_code,client_no,branch_agent,comm_rate,commence_date,renewal_date,loan_yn,load_rate,nra,total_members,with_branches,unit_rate_yn,unit_rate,salary_indicator,period_from,period_to) values('".$_POST['policy_no']."', 
	         ".$_POST['uw_year'].",
	         ".$_POST['class_code'].",
	         '".$_POST['client']."',
		     ".$_POST['agname'].",
		     ".$_POST['comm_rate'].",
			 ".$_POST['commence_date'].",
			 ".$_POST['renewal_date'].",
			 ".$_POST['load_yn'].",
			 ".$_POST['load_rate'].",
			 ".$_POST['nra'].",
			 ".$_POST['total_members'].",
			 '".$_POST['with_branches']."',
			 ".$_POST['unit_rate_yn'].",
			 ".$_POST['unit_rate'].",
			 ".$_POST['salary_indicator'].",
			 ".$_POST['period_from'].",
			 ".$_POST['period_to'].")";

	 mysql_query($sqlinsert) or die(mysql_error());

	 header("location:glscheme_inserted.php");
   }
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Group life-Scheme details </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Francis" CONTENT="">
<META NAME="group life,insurance,aims" CONTENT="">
<META NAME="index file" CONTENT="">

<link rel="STYLESHEET" href="css/stylesheet.css" type="text/css">

<script language="javascript" type="text/javascript">

//Browser Support Code
function ajaxFunction()
{
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try
	{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} 
	catch (e)
	{
		// Internet Explorer Browsers
		try
		{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try
			{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e)
			{
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	} 

	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function()
									 {
		                               if(ajaxRequest.readyState == 4)
									   {
											var ajaxDisplay = document.getElementById('company_name');
											ajaxDisplay.innerHTML = ajaxRequest.responseText;
									   }
									 }
	var client_no = document.getElementById('client').value;
	
	var queryString = "?client_no=" + client_no;
//	alert(queryString);
	ajaxRequest.open("GET","glclient.php" + queryString, true);
	ajaxRequest.send(null); 

}

/*
	ajaxRequest.onreadystatechange = function()
									 {
		                               if(ajaxRequest.readyState == 4)
									   {
											var ajaxDisplay = document.getElementById('branch_agent');
											ajaxDisplay.innerHTML = ajaxRequest.responseText;
									   }
									 }
	var branch_agent = document.getElementById('agname').value;
	
	var queryString = "?branch_agent=" + branch_agent;
	//alert(queryString);
	ajaxRequest.open("GET","branch_ag.php" + queryString, true);
	ajaxRequest.send(null); 
*/
}



function popup(mylink, windowname)
{
if (! window.focus)
	return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=400,height=200,scrollbars=no');
return false;
}
   </script> 

</HEAD>

<BODY>
<form name="glscheme" action="" method=post >

<TABLE bgcolor="#C0C0C0" width="80%" height="100%" border="1" align ="center"  border="1" cellspacing="0" cellpadding="0">
<tr>
   <td colspan=2 height="100" valign="bottom"><?php include("header.php");?></td>
</tr>
<tr>
 <td>
<table border="1" width="100%" height="100%" cellspacing="0" cellpadding="0">
 <tr>
 <td width="150" valign="top" bgcolor="#3399CC"><?php include("glscheme_navigator.inc.php");?></td>
 <td bgcolor="white"> 
     <!---------------------------------------------------Start of body content----------------------------------------------->
       <table border="0" width="100%" height="100%" cellspacing="0" cellpadding="0">
<TR>
	<TD valign=top><div align="right">Policy No</div></td>
	<td width="50"><INPUT TYPE="text" NAME="policy_no" width = 9></td>
	<td><div align="right">UW Year</td>
	<td><INPUT TYPE="text" NAME="uw_year" width = 4></td>
	<td><div align="right">Class</td>
	<td><select name='class_code'>
	                    <option value=100>--Select--</option>
						<?php while($row=mysql_fetch_array($processselect))
						      {?>
							  <option value=<?php $row['class_code']?>><?php echo $row['class_code'];?></option>
						      <?php }?>
					 </select>&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR>
	   <td><div align="right">Group No</td>
       <td><select name="client" onchange="ajaxFunction();">
	                    <option value=100>--Select--</option>
						<?php while($rowc=mysql_fetch_array($processselectclt))
						      {?>
							  <option value=<?php echo $rowc['client_no'];?>><?php echo $rowc['client_no'];?></option>
						      <?php }?>
					 </select></td>

<td  width=100><div align="right">Name</td>
	   <td bgcolor=yellow  width=100><div id="company_name" bgcolor=red><?php echo $rowc['company_name']; ?></div></td>
	   <td>&nbsp;</td>
	   <td>&nbsp;</td>
</tr>

<TR>
	   <td><div align="right">Broker/ Agent Code</td>
	   <td><select name="agname" onchange="ajaxFunction();">
	                    <option value=99999999>--Select--</option>
						<?php while($row=mysql_fetch_array($processselectagnam))
						      {?>
							  <option value=<?php echo $row['branch_agent'];?>><?php echo $row['branch_agent'];?></option>
						      <?php }?>
					 </select></td>
	   <td  width=100><div align="right">Agent Name</td>
	   <td bgcolor=yellow  width=100><div id='description' bgcolor=red></div></td>

	<td><div align="right">Commission</td>
	<td><INPUT TYPE="text" NAME="comm_rate" width = 4></TD>
	
</TR>


<TR>
	<TD valign=top><div align="right">Commencement Date</td>
	<td><INPUT TYPE="text" NAME="commence_date" width = 9></td>
	<td><div align="right">Renewal Date</td>
	<td><INPUT TYPE="text" NAME="renewal_date" width = 9></TD>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
</TR>
<TR>
	<TD valign=top><div align="right">Premium Loading</TD>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
</TR>
<TR>
	<TD valign=top><div align="right">Applicable YN</td>
	<td><select name="load_yn">
	     <option>---Select---</option>
		 <option value="Y">Yes</option>
		 <option value="N">No</option>
		</select>
		</td>
	<td><div align="right">Rate</td>
	<td><INPUT TYPE="text" NAME="load_rate" width = 9></TD>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
</TR>
<TR>
		<TD valign=top><div align="right">NRA</td>
		<td><INPUT TYPE="text" NAME="nra" width = 4></td>
		<td><div align="right">Total Members</td>
		<td><INPUT TYPE="text" NAME="total_members" width=4></td>
		<td><div align="right">With Branches</td>
		<td><select name='with_branches'>
	                    <option >--Select--</option>
						<option value="Y">Yes</option>
						<option value="N">No</option>
						</select>&nbsp;&nbsp;&nbsp;&nbsp;</TD>
		
		
</TR>
<TR>
	<TD valign=top><div align="right">Unit Rate</TD>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
</TR>
<TR>
		<TD valign=top><div align="right">Applicable YN</td>
		<td><INPUT TYPE="text" NAME="unit_rate_yn" width = 2></td>
		<td><div align="right">Rate</td>
		<td><INPUT TYPE="text" NAME="unit_rate" width = 9></TD>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
</TR>
<TR>
	<TD valign=top><div align="right">Salary</td>
	<td>&nbsp;</td>
	<td><div align="right">Period</TD>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
</TR>
<TR>
			<TD valign=top><div align="right">Indicator</td>
			<td><INPUT TYPE="text" NAME="salary_indicator" width = 4></td>
			<td><div align="right">From</td>
			<td><INPUT TYPE="text" NAME="period_from" width=4></td>
			<td><div align="right">To</td>
			<td><INPUT TYPE="text" NAME="period_to" width = 1></TD>
</TR>

<TR>
	<TD colspan=6><div align="center"><INPUT TYPE="submit" value ="SAVE"></div></TD>
</TR>
</table>
     <!---------------------------------------------------End of body content----------------------------------------------->
</td>
 </tr>
</table>
 </td>
</tr>
<tr>
  <td colspan=2 height="5"><?php include("copyright.php");?>
  </td>
</tr>
</TABLE>

</form>
</BODY>
</HTML>



This is a copy of the glclient.php

<?php
    include("config.php");

	// Retrieve data from Query String
    $client_no = $_GET['client_no'];

	// Escape User Input to help prevent SQL Injection
    $client_no = mysql_real_escape_string($client_no);

	//build query
    $query = "select company_name from laclnt where client_no='".$client_no."'";

	//Execute query
    $qry_result = mysql_query($query) or die(mysql_error());

	$rowc=mysql_fetch_array($qry_result);

	//Build Result String
	// echo "<select name='sector'> <option value=-1>---Select---</option>";
													     
	 echo $rowc['company_name'];
	
?>



Is This A Good Question/Topic? 0
  • +

Page 1 of 1