-2

我必须使用两个自动完成框,但只有第一个框有效。两个字段的关键字相同,例如位置 1 的一个自动完成字段和位置 2 的另一个字段。这是一个自动完成字段框的工作代码:

<html>
<head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            var data = ["Boston Celtics", "Chicago Bulls", "Miami Heat", "Orlando Magic", "Atlanta Hawks", "Philadelphia Sixers", "New York Knicks", "Indiana Pacers", "Charlotte Bobcats", "Milwaukee Bucks", "Detroit Pistons", "New Jersey Nets", "Toronto Raptors", "Washington Wizards", "Cleveland Cavaliers"];
            $("#seed_one").autocomplete({source:data});
        });
    </script>
</head>

<body>
    <input id="seed_one" type="text" name="seed_one"/>
</body>
</html>
4

1 回答 1

2

对于另一个自动完成框,您创建了另一个输入框并将其传递idautocomplete函数。

<script type="text/javascript">
    $(document).ready(function(){
        var data = ["Boston Celtics", "Chicago Bulls", "Miami Heat", "Orlando Magic", "Atlanta Hawks", "Philadelphia Sixers", "New York Knicks", "Indiana Pacers", "Charlotte Bobcats", "Milwaukee Bucks", "Detroit Pistons", "New Jersey Nets", "Toronto Raptors", "Washington Wizards", "Cleveland Cavaliers"];
        $("#seed_one").autocomplete({source:data});
        $("#seed_two").autocomplete({source:data});
    });
</script>
<body>
<input id="seed_one" type="text" name="seed_one"/>
<input id="seed_two" type="text" name="seed_two"/>
</body>
于 2013-06-22T07:03:33.443 回答