Skip to content

Instantly share code, notes, and snippets.

@ptahdunbar
Created September 25, 2015 02:11
Show Gist options
  • Save ptahdunbar/1dfd056214160ecbf767 to your computer and use it in GitHub Desktop.
Save ptahdunbar/1dfd056214160ecbf767 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js" charset="utf-8"></script>
<script>
function showHint(str) {
console.log(str)
jQuery.get("gethint.php?q=" + str, function(data){
document.querySelector('#txtHint').innerHTML = data;
});
return false;
}
</script>
</head>
<body>
<p><b>Start typing a name in the input field below:</b></p>
<form>
First name: <input type="text">
</form>
<p>Suggestions: <span id="txtHint"></span></p>
</body>
<script>
document.getElementsByTagName('form')[0].onsubmit = function () {
showHint(document.getElementsByTagName('input')[0].value);
return false;
};
//showHint(document.getElementsByTagName('input')[0].value));
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment