Skip to content

Instantly share code, notes, and snippets.

@Error-331
Created February 1, 2012 13:54
Show Gist options
  • Save Error-331/1717029 to your computer and use it in GitHub Desktop.
Save Error-331/1717029 to your computer and use it in GitHub Desktop.
Test
<html>
<head>
<title>Autocomplete</title>
<style>
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
var suggestions = new Array("America", "Armenia", "Dallas", "Canada", "Nikolaev");
function Copy()
{
alert('v');
}
function FindAuto()
{
var tmpTextVal = document.getElementById('autoinput').value;
var tmpDiv = document.getElementById('AutoText');
tmpDiv.innerHTML = '';
for (Counter1 = 0; Counter1 < suggestions.length; Counter1++)
{
if (tmpTextVal.toLowerCase() == suggestions[Counter1].substr(0, tmpTextVal.length).toLowerCase())
{
tmpDiv.innerHTML += '<span>'+ suggestions[Counter1] + '</span>' + '<br/>';
}
}
$('#AutoText span').bind('click', function(event) {
document.getElementById('autoinput').value = $(this).text();
});
}
</script>
</head>
<body>
<form name="AutoForm">
<input type="text" name="text" id="autoinput" onkeyup="javascript:FindAuto();"/>
<div id="AutoText">
</div>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment