$ (function() {
var heroes = {
"Abaddon":{
"counters": "Undying" + "Anti-Mage" + "Outworld Devourer" + "Shadow Demon" + "Techies" + "Ancient Apparition" + "Meepo" + "Riki"
},
"Alchemist":{
"counters": "Riki" + "Ursa" + "Drow" + "Phantom Assassin" + "Troll Warlord" + "Bounty Hunter" + "Slark" + "Lifestealer"
},
"Ancient Apparition":{
"counters": "Anti-Mage" + "Clinkz" + "Riki" + "Juggernaut" + "Zeus" + "Techies" + "Phantom Assassin" + "Spectre"
},
"Axe":{
"counters": "Timbersaw" + "Venomancer" + "Silencer" + "Necrophos" + "Zeus" + "Phoenix" + "Lich" + "Ancient Apparition"
},
"Bane":{
"counters": "Phantom Lancer" + "Chaos Knight" + "Meepo" + "Tidehunter" + "Sand King" + "Razor" + "Naga Siren" + "Undying"
},
"Batrider":{
"counters": "Huskar" + "Viper" + "Juggernaut" + "Sniper" + "Venomancer" + "Undying" + "Weaver" + "Drow Ranger"
},
"Beastmaster":{
"counters": "Axe" + "Bristleback" + "Lich" + "Timbersaw" + "Zeus" + "Meepo" + "Centaur Warrunner" + "Tidehunter"
},
"Bloodseeker":{
"counters": "Wraith King" + "Techies" + "Tiny" + "Troll Warlod" + "Lifestealer" + "Dragon Knight" + "Legion Commander" + "Chaos Knight"
},
"Bounty Hunter":{
"counters": "Phantom Lancer" + "Slardar" + "Meepo" + "Naga Siren" + "Bloodseeker" + "Chaos Knight" + "Huskar" + "Techies"
},
"Brewmaster":{
"counters": "Undying" + "Omniknight" + "Death Prophet" + "Timbersaw" + "Weaver" + "Techies" + "Queen of Pain" + "Anti-Mage"
},
"Bristleback":{
"counters": "Necrophos" + "Venomancer" + "Viper" + "Ancient Apparition" + "Razor" + "Death Prophet" + "Clockwerk" + "Omniknight"
},
};
var keys = [];
for(var k in heroes) keys.push(k);
$("#searchBar").autocomplete({
source: keys
});
$( "#searchBar" ).autocomplete({ minLength: 2 });
var minLength = $( "#searchBar" ).autocomplete( "option", "minLength" );
$( "#searchBar" ).autocomplete( "option", "minLength", 2 );
$( "#searchBar" ).autocomplete({ autoFocus: true });
$( "#searchBar" ).autocomplete({response: function( event, ui ) {} });
$("#searchBar").bind("keypress", function(e) {
var key = e.keyCode || e.which;
if(key == 13) {
for (var i = 0; i < heroes.length; i++) {
if (document.getElementById("searchBar").value == heroes);
document.getElementById("placeholder").innerHTML = heroes.counters;
};
}
});
});
So basically what I'm trying to build is a counter hero list. what I want to achieve is that when I put a string into the input field (#searchBar) it will run it through my object and see if it matches, it it matches it will return the value(counters, but it's not working.