jQuery的同一页面上的许多自动完成 [英] Jquery Many autocompletes on the same page

查看:123
本文介绍了jQuery的同一页面上的许多自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现对一个jsp做了一个处方的jQuery的自动完成功能。

I'm trying to implements the autocomplete function of Jquery on a formulary made on a jsp.

我有一个textarea的没有问题,但不可能做到这一点与很多。

I have no problems for one textarea, but impossible to do that with many of them.

这是$ C $我的网页CS:
我用推手创建列表引起的数据都是从Java豆进口。这code是创建页面的结果运行的应用程序后,用CTRL-U捕获。

This is the codes of my page: I use pushs to create the lists cause datas are imported from a java bean. This code is the result of the page creation after running the application and caught with CTRL-U.

        <script>
        $(function()
        {
            var TagsEntis = new Array();

                TagsEntis.push("MAIRIE");

                TagsEntis.push("COMMUNAUTE URBAINE");

                <!--Others pushs here-->

            $( "#tagsentis" ).autocomplete({source: TagsEntis});
        });
        </script>
        <script>
        $(function()
        {
            var TagsNames = new Array();

                TagsNames.push("CAPILLON");

                TagsNames.push("DUFOUR");

                TagsNames.push("STARON");

                <!--Others pushs here-->

            $( "#tagsnames" ).autocomplete({source: TagsNames});
        });
        </script>

和使用这些标签的文字区域后定义:

And after the definition of the textareas using these tags:

           <form method="post" action="form.htm" name="formulary">
                <table id="formulary">
                   <tr>
                        <td>
                            Entity
                        </td>
                        <td>
                            <spring:bind path="PersonForm.entity">
                                <input id="tagsentis" type="text" name="entity"
                                       value=""/>
                            </spring:bind>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            LastName
                        </td>
                        <td>
                            <spring:bind path="PersonForm.lastname">
                                <input id="tagsnames" type="text" name="lastname"
                                       value=""/>
                            </spring:bind>
                        </td>
                    </tr>

这code工作,但只是为姓氏textarea的。

This code works, but just for the LastName Textarea.

你能帮助我吗?

感谢你这么多提前;)

推荐答案

您可以找到2自动完成输入字段的演示(不textarea的)在这里。
你能给ES更datails它是如何不工作。你得到的的java脚本控制台任何错误

You can find a demo of 2 autocomplete input-fields (not textarea) here. Could you give es more datails how it is not working. Do you get any errors in the java-script console

$(function() {
    var availFirstNames = [
        "Adam", "Anna", "Anita",
        "Bert", "Bob", "Chuck", "Claudia", "Douche", "Ernie",
        "Gib", "Henry", "Jesus", "John", "Lisp", "Perl",
        "PHP", "Python", "Ruby", "Scala", "Scheme"
    ];
    var availLastNames = availFirstNames;
    $( "#FirstName" ).autocomplete({
        source: availFirstNames
    });
    $( "#LastName" ).autocomplete({
        source: availLastNames
    });        
});

和HTML

<div class="ui-widget">
    <label for="tags">Names: </label>
    <input id="FirstName" />
    <input id="LastName" />
</div>​

这篇关于jQuery的同一页面上的许多自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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