I am working in web page that can support autocomplition more times. If I write d , program will offer me dari. Ok, but I want be able to put more then one text in textbox. So I press ; and I start write new input and program offer me again good, but he delete previous option.
index.html
<title>Auto Complete Input box</title>
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.autocomplete.js"></script>
<script>
$(document).ready(function(){
$("#tag").autocomplete("autocomplete.php", {
//selectFirst: true
});
});
</script>
</head>
<body>
<label>Tag:</label>
<input name="tag" type="text" id="tag" size="150"/>
</body>
</html>
autocomplete.php
<?php
$q=$_GET['q'];
$my_data=mysql_real_escape_string($q);
$my_data2=$my_data;
$pos=0;
for($i=0;$i<strlen($my_data);++$i)
{
if($my_data[$i]==';')$pos=$i;
}
$s="";
if($pos!=0){
for($i=$pos+1;$i<strlen($my_data);++$i)$s.=$my_data[$i];
$my_data=$s;}
$mysqli=mysqli_connect('localhost','root','','raspored') or die("Database Error");
$sql="SELECT ime FROM korisnici WHERE ime LIKE '%$my_data%' ORDER BY ime";
$result = mysqli_query($mysqli,$sql) or die(mysqli_error());
if($result)
{
while($row=mysqli_fetch_array($result))
{
echo $row['ime']."\n";
}
}
?>
You have to extend the autocomplete plugin
to get this.
You can see an example here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.