0
<?php
include('connection/database.php');
require ('xajax/xajax_core/xajax.inc.php');
$xajax = new xajax();
function autocomplete($val)
{
	if($val!="")
	{
	$query=mysql_query("select * from name where name like '".$val."%'");
	$rows=mysql_num_rows($query);
	$out="<table width='100%' bgcolor='#bfbfc3'>";
	while($data=mysql_fetch_array($query))
	{
			$out.="<tr><td>".$data['name']."</td></tr>";
}
$out.="</table>";
	$objResponse=new xajaxResponse();
	$objResponse->assign('div1','innerHTML',$out);
	$objResponse->script("jQuery:$('td').click(function(){
	var a=$(this).attr('innerHTML');
    $('#name').attr('value',a);
    $('#div1').attr('innerHTML','');
  });
  $('td').mouseover(function(){
	  $(this).css('background-color','gray');
	  });
   $('td').mouseout(function(){
	  $(this).css('background-color','');
	  });
  ");
	return $objResponse;
}
else
{
	$objResponse=new xajaxResponse();
	$objResponse->assign('div1','innerHTML',"");
	return $objResponse;
}
}
$auto =& $xajax->registerFunction('autocomplete');
$auto->setParameter(0, XAJAX_INPUT_VALUE, 'name');
$xajax->processRequest();
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title>Autocompleter</title>
<?php
	$xajax->printJavascript('xajax/');
?>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="a.js"></script>
</head>
<body>
	<input type="text" name="name" id="name" onkeyup='<?$auto->printScript();?>' width="180px" />
	<div id="div1" name="div1" style=" position:relative; z-index=0; left:3px; height:120px; overflow:auto; width:179px;  top:-1px; bottom:80px;" ></div>
	<span style="position:absolute; top:50px; z-index:-1;">jhlkjlkdasas</span>
</body>
</html>

Edited by Ezzaral: Fixed code tags.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by pritaeas
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.