jquery.ajax-combobox
Version:
jQuery plugin to create a text box which can auto-complete and pull-down-select.
41 lines • 1.14 kB
HTML
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>After select: "is_enter_key": jquery.ajax-combobox</title>
<link rel="stylesheet" href="../../dist/css/jquery.ajax-combobox.css">
<script src="../../node_modules/jquery/dist/jquery.min.js"></script>
<script src="../../dist/js/jquery.ajax-combobox.min.js"></script>
<script>
$(function() {
$('#foo').ajaxComboBox(
'../../dist/php/jquery.ajax-combobox.php',
{
db_table: 'nation',
bind_to: 'foo'
}
)
.bind('foo', function(e, is_enter_key) {
if (!is_enter_key) {
$('#result').text($(this).val() + ' is selected. (by mouse)');
}
})
.keydown(function(e) {
if(e.keyCode == 13) {
$('#result').text($(this).val() + ' is selected. (by enter key)');
}
});
});
</script>
</head>
<body>
<h1>After select: "is_enter_key": jquery.ajax-combobox</h1>
<form action="send.php" method="post">
<label for="foo">Nation:</label><br>
<input id="foo" name="foo" type="text">
<p><button type="submit">Send</button></p>
</form>
<div id="result"></div>
</body>
</html>