【问题标题】:Autocompletion textbox html自动完成文本框 html
【发布时间】:2014-01-04 18:30:04
【问题描述】:

我正在处理可以支持更多次自动完成的网页。如果我写 d ,程序将为我提供 dari。好的,但我希望能够在文本框中放置多个文本。所以我按;我开始编写新的输入,程序再次为我提供了很好的服务,但他删除了以前的选项。

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>

自动完成.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";
  }
 }
?>

【问题讨论】:

  • 对于自动完成数据必须采用标签和值数组的格式..否则你必须使用 $.map 映射它们

标签: javascript php html autocomplete


【解决方案1】:

你必须extend the autocomplete plugin 才能得到这个。

你可以看一个例子here

【讨论】:

    猜你喜欢
    • 2013-06-30
    • 2011-04-18
    • 2010-09-22
    • 1970-01-01
    • 2012-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多