制作自动完成的文本框/输入区域 [英] Making a autocomplete textbox/input area

查看:100
本文介绍了制作自动完成的文本框/输入区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个 jQuery自动完成输入框,以便人们可以看到预先设置的建议.其实并不难,但是某种程度上,我似乎无法解决不会显示建议的问题.

I am trying to make a jQuery autocomplete inputbox, so that people can see suggestions that are pre-set. Not that hard actually, but somehow, I can't seem to solve a problem which won't show up the suggestions.

这是一个小提琴: http://jsfiddle.net/tbBy6/

这是我的HTML文件:

And this is my HTML file:

<head>
  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
  <script>
  $(document).ready(function() {
    $("input#search-textbox").autocomplete({
    source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
});
  });
  </script>
</head>

文本框:

<body>
<input id="search-textbox" class="topic-picker ui-autocomplete-input" type="text" maxlength="100" name="q" accesskey="b"  autocomplete="off" placeholder="enter text" role="textbox" aria-autocomplete="list" aria-haspopup="true">

为什么我例如输入"java"就看不到建议?

Why can't I see a suggestion if I type "java" for example?

我的第二个问题:如何从数据库中获取要提取的数据?

PS:我从这里使用代码: http://docs.jquery.com /UI/API/1.8/自动完成

PS: I used the code from here: http://docs.jquery.com/UI/API/1.8/Autocomplete

推荐答案

如果要在小提琴中进行测试,则需要将左侧的框架更改为jQuery,而不是MooTools,并且还需要包括jQuery UI.

If you're testing in the fiddle you need to change the framework on the left to jQuery, not MooTools, and you will also need to include jQuery UI.

尝试一下:

更新的小提琴

这篇关于制作自动完成的文本框/输入区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆