自定义 jQuery UI 自动完成

发布于 2024-09-08 23:22:12 字数 515 浏览 1 评论 0原文

我想对 jQuery UI Autcomplete 进行一些自定义:

1)如果没有找到结果,它应该在列表中输出“未找到结果”。

2)是否可以在输入结果时突出显示/加粗结果中的字母?例如,如果我输入“ball”并且结果中有“football”,则需要输出为 foot ball

3) 顶部显示的结果是否可能与细绳。例如,假设我的数据库中有 3 个条目:

  • Astrologer
  • Space Station
  • Star

我开始输入“st” - 这将按该顺序显示这 3 个条目。但我希望“Star”成为第一个结果。

目前用于生成结果的 MySQL 查询是:

$query = mysql_query("SELECT id, name FROM customer WHERE name LIKE '%".$_GET['term']."%' ORDER BY name");

I want to make a few customizations to jQuery UI Autcomplete:

1) If there are no results found it should output "no results found" in the list.

2) Is it possible to highlight/bold the letters in the results as they are being typed? For example if I type "ball" and I have "football" in my results it needs to output as foot ball

3) Is it possible for the results that appear at the top to match the beginning of the string. For example suppose I have 3 entries in my database:

  • Astrologer
  • Space Station
  • Star

I start typing "st" - this will bring up those 3 entries in that order. But I want "Star" to be the first result.

The MySQL query being used at the moment to generate the results is:

$query = mysql_query("SELECT id, name FROM customer WHERE name LIKE '%".$_GET['term']."%' ORDER BY name");

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你丑哭了我 2024-09-15 23:22:12
  1. 如果 mysql_query 中的 num 行为 0,您可以在返回列表的脚本中简单地回显“未找到结果”。

    如果

  2. 这在 原始 Autocomplete 插件中是可能的,但是我在 JQuery UI 文档中看不到它。

  3. 您可能必须运行两个单独的 mysql 查询 - 第一个查找 LIKE '".$_GET['term']."%' ,第二个查询为您拥有的,但不包括您已经得到的结果从第一个查询中获得。

  1. You can simply echo 'No results found' inside the script that returns the list if num rows from your mysql_query is 0.

  2. This was possible in the original Autocomplete plugin but I can't see it anywhere in the JQuery UI documentation.

  3. You may have to run two separate mysql queries - the first one looking for LIKE '".$_GET['term']."%' and the second one as you have it, but excluding the results you've already got from the first query.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文