I'm using scriptaculous autocomplete for my text box and it works perfectly ok
i have made server.php for fetching the values in the ul list and it is shown correctly on the main form but after selection of the value from the text box i want to query my database further for some more details depending on that value
but i don't get any records although my table has records.
if i alert ar values in showcode function it shows rows with values correctly but doesnt show int he div container
if itry to create that table in the main form taking the values of $c_cde it and then create rows of the existing data it doesnt show any rows
instead of generating the rows int he server.php
because it doesnt get $c_Cde value there i checked alerting it
where am i going wrong
my code goes here
[PHP]<form method="get">
<table id="tbl">
<tr>
<td bordercolor="#669999">
<label><strong><font size="3">Select country</strong></label></td>
<td colspan="11" bordercolor="#669999">
<input type="text" c_name="c_name" id="c_name" size="40" class="dlight" autocomplete="off" onblur="showCode(this.value);">
<div id="hint"></div>
<script type="text/javascript">
new Ajax.Autocompleter("c_name","hint","server.php");
</script>
<input type="text" name="c_code" id="countrycode" size="8" class="dlight" value="<?=$c_code?>" >
<div id="tbl1"></div>
<tr><td><input type="text" name="isdcode" id="isdcode" value="<?=$misdcode?>"></td>
<td><input type="text" name="continent" id="continent" value="<?=$mcontinent?>"></td></tr>
</table>
</form>[/PHP]
and my server.php if as follows
[PHP]<?php
include("../include/con.php");
$sql = "select c_code,c_name from countrymaster where c_name like '%" . $_GET['c_name'] . "%'";
$rs = $DB_site->query($sql);
?>
<ul>
<? while($data = $DB_site->fetch_array($rs)) { ?>
<li><? echo stripslashes($data['c_name']."-".$data['c_cde']);
?></li>
<? } ?>
</ul>
<?
if($_GET['c_name']!=""){
$mc_name=$_GET['c_name'];
$mc_cde=$_GET['c_cde'];
echo "|".$mc_cde."|";
}
$sql1="select * from countrydetails where c_cde='".$mc_cde."'";
$db_query_pricelist=$DB_site->query($sql1);
while($rs=$DB_site->fetch_array($db_query_rs)){
$misdcode=$rs[isdcode'];
$mcontinent=$rs['continent'];
?>
<tr><td><?=$misdcode;?></td>
<td><?=$mcontinent;?></td>
</tr>
<? } ?>[/PHP]
in showcode function
Expand|Select|Wrap|Line Numbers
- function showCode(str){
- c_name=str.substr(0,str.indexOf("-"));
- c_cde=str.substr(str.indexOf("-")+1);
- xmlHttp=GetXmlHttpObject();
- if (xmlHttp==null){
- alert ("Browser does not support HTTP Request");
- return;
- }
- var url="server.php";
- url=url+"?c_cde="+c_cde+"&c_name="+c_name; url=url+"&sid="+Math.random();
- xmlHttp.onreadystatechange=function(){stateChanged()} ;
- xmlHttp.open("GET",url,true);
- xmlHttp.send(null);
- }
- function stateChanged() {
- if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
- {
- var ar=xmlHttp.responseText.split("|");
- al=ar.length;
- document.getElementById("c_cde").value=ar[1] ;
- document.getElementById("tbl1").innerHTML=ar[2] ;
- }
- }