I have implemented jquery autocomplete with double sources like below
var selectedItemUrl = "";
$(function() {
var source = [{
value: "YA",
url: 'http://www.yahoo.com'
}];
and this
var selectedItemUrl1 = "";
$(function() {
var source1 = [{
value: "Go",
url: 'http://www.google.com'
}];
The below is the full code which i have tried with 2 tags
<!doctype html>
<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>
<script>
var selectedItemUrl = "";
$(function() {
var source = [{
value: "YA",
url: 'http://www.yahoo.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")
}
var selectedItemUrl1 = "";
$(function() {
var source1 = [{
value: "Go",
url: 'http://www.google.com'
}];
$("#autocomplete").autocomplete({
minLength: 0,
source1: source1,
select: function(event, ui) {
selectedItemUrl1 = ui.item.url
}
})
});
function SearchItem(e){
if(selectedItemUrl1!="")
window.location=selectedItemUrl1
else
alert("select something to search")
}
</script>
<input id="autocomplete" />
<button onclick='SearchItem()'>
Search
</button>
</!doctype>
The below is the code which i have implemented without 2 tags and i got sucess with below but not able to done like i said above.
<!DOCTYPE html>
<html>
<head>
<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>
<script>
var selectedItemUrl = "";
$(function() {
var source = [{
value: "YA",
url: 'http://www.yahoo.com'
}, {
value: "GO",
url: 'http://www.google.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>
</head>
<body>
<input id="autocomplete" />
<button onclick='SearchItem()'>
Search
</button>
</body>
</html>
As i said below my aim is to implement give 2 values separately.
