从PHP mySQL查询jQuery自动完成

时间:2013-10-04 23:19:12

标签: javascript php jquery html mysql

我正在尝试按照自动完成的教程:http://www.jensbits.com/2010/03/29/jquery-ui-autocomplete-widget-with-php-and-mysql/

如果有人有建议,我会向其他人开放,但我离题了。 我想输入一个客人的姓氏,并在下面显示所有匹配的列表。然而,我得到一些真正的东西,它说“1个结果可用,使用向上和向下箭头键进行导航。”在我可以点击的文本中的某处有一个小点,这将填充我的只读文本框。如何使其正常运行?老实说我不知道​​我哪里出错了。我将发布我的HTML和jQuery。我的php显然工作正常,所以我觉得没必要发帖。

<div class="guestinfo">
    <p class="ui-widget">
        <div><label>Exisiting Guest List</label></br>
        <input type="text" name="guests" id="guests"/></div>
        <input readonly="readonly" type="text" id="firstname" name="firstname"/>
        <input readonly="readonly" type="text" id="lastname" name="lastname"/>

        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
        <script>
            $(function() {
                $('#guests').val("");

                $("#guests").autocomplete({
                    source: "classes/autocomplete_guests.php",
                    minLength: 2,
                    select: function(event, ui) {
                        $('#firstname').val(ui.item.fname);
                        $('#lastname').val(ui.item.lname);
                    }
                });
            });

        </script></p>

1 个答案:

答案 0 :(得分:1)

这是一个辅助功能,您可以在css中轻松解决此问题,请尝试在样式表中添加:

.ui-helper-hidden-accessible {
    display:none;
}