gpt4 book ai didi

php - 使用 JQuery 自动完成的搜索功能

转载 作者:行者123 更新时间:2023-11-30 01:30:52 25 4
gpt4 key购买 nike

我正在开发一个涉及为字典数据库创建接口(interface)的项目。我能够创建一个简单的搜索栏,可以提取正确的信息。之后,我能够使用 jQuery 为文本框实现自动完成功能。现在,我在使用搜索功能时遇到问题。如果我提交表单,它会重定向到适当的脚本,但不会将文本框值发送到脚本。

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>JQuery autocomplete example with database accessing</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css">
input.submit {
width:30px;
height:30px;
cursor:pointer;
background-image:url('../search-button.jpg');
</style>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(function() {
$( "#searchbox" ).autocomplete({
source: "data.php",
minLength: 1
});
});
</script>
</head>
<body bgcolor="#E6E6FA">
<div style="background-color:#d4e7b2;text-align:left">
<form action="../test.php" method="get" style="margin-left:1cm;">
<div class="ui-widget">
<input id="searchbox"/>
<input class="submit" type="submit" value="" style="position:absolute;margin:0px 0 0 0px;"/>
</div>

</form>
<br>
</div>
</body>
</html>

自动完成功能运行良好,但按下搜索按钮会导致页面重定向到“/test.php?”没有定义的 GET 变量。

非常感谢任何和所有帮助!

最佳答案

您需要将名称添加到您的搜索框输入中。
改变

<input id="searchbox"/>

<input name="searchbox" id="searchbox" />

关于php - 使用 JQuery 自动完成的搜索功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17478434/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com