我正在使用 jquery 自动完成功能。我正在从数据库中获取搜索结果。
基本上,当我开始在搜索框中输入内容时,我会得到一些建议。我已经使用 <a href="results.html>
给出了结果链接。 .但是当我点击这些建议时,我没有得到 results.html
我需要根据一些建议重定向到 results.html 页面,我该怎么做?
代码:Jquery
$().ready(function() {
$("#search").autocomplete("php/getvalues.php", {
width: 383,
matchContains: true,
//mustMatch: false,
//minChars: 0,
//multiple: true,
//highlight: true,
//multipleSeparator: ",",
selectFirst: false
});
});
获取值.php
<?php
require_once "config.php";
$q = strtolower($_GET["q"]);
if (!$q) return;
$sql = "select file_name,img_url,captions from completer";
$rsd = mysql_query($sql);
while($rs = mysql_fetch_array($rsd)) {
$fname = $rs['file_name'];
$iurl = $rs ['img_url'];
$caption = $rs ['captions'];
echo '<a href="results.html" class="searchres" style="color:#696969;text-decoration:none;"><img src='.$iurl.' class="icons" /><div class="results" style="color:#696969;text-decoration:none;">'."$fname".'</div><span style="color:#696969;text-decoration:none;" class="author">'.$caption.'</span></a>'."\n";
}
?>
html:
<form method="post" name="myform" class="ourform">
<input type="search" id="search" name="search" placeholder="Type or speak here to search">
<input type="image" alt="submit" src="images/search.jpg" class="submit"/>
</form>
最佳答案
您需要像这样在表单元素中放置一个 Action :
<form method="post" name="myform" class="ourform" action="/results.html">
关于javascript - Jquery 自动完成结果链接在点击时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29947737/