在This博客我已成功创建jquery自动完成与搜索按钮成功。但我想,就像This如何将重复搜索框添加到jquery自动完成
我的搜索框的目标选择tags->重定向到另一个页面..
我的问题是我想多加一个搜索框,只需按动一个按钮只有我的意思是搜索领域的我的意思是搜索区域应2相同的链接,我的意思是我修改像邮政编码链接和城市链接的链接后,但我目前需要使用多个搜索领域,我希望我的问题是明确的,上面一个搜索按钮是我的代码
var selectedItemUrl = "";
$(function() {
var source = [{
value: "NYC",
url: 'http://www.nyc.com'
}, {
value: "LA",
url: 'http://www.la.com'
}, {
value: "Philly",
url: 'http://www.philly.com'
}, {
value: "Chitown",
url: 'http://www.chitown.com'
}, {
value: "DC",
url: 'http://www.washingtondc.com'
}, {
value: "SF",
url: 'http://www.sanfran.com'
}, {
value: "Peru",
url: 'http://www.peru.com'
}];
$("#autocomplete").autocomplete({
minLength: 0,
source: source,
select: function(event, ui) {
selectedItemUrl = ui.item.url
}
})
});
function SearchItem(e) {
if (selectedItemUrl != "")
window.location = selectedItemUrl
else
alert("select something to search")
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js">
</script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<input id="autocomplete" />
<button onclick='SearchItem()'>search
不清楚究竟ü要实现 –
这样http://www.indeed.co.in/我需要什么我的意思是只有一个按钮与不同的搜索字段我已经添加了一个搜索字段与一个按钮,但无法添加另一个搜索字段的链接,因为我上面解释 – Stackz
你不应该打开从J的多个链接S,它很容易被最终用户浏览器阻止。 – Yuri