Untitled
By: a guest | Mar 22nd, 2010 | Syntax:
None | Size: 1.54 KB | Hits: 54 | Expires: Never
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="Autocompleter.css" type="text/css" media="screen">
<script type="text/javascript" src="jquery.js"></script>
<script type='text/javascript' src='jquery.autocomplete.js'></script>
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
<script type="text/javascript">
//$("#course").autocomplete().bind("autocompleteselect",fn);
$().ready(function() {
$("#course").autocomplete("query_user.php", {
width: 260,
matchContains: true,
scroll: true,
onItemSelect:test2,
selectFirst: false
});
});
function test() {
alert(document.getElementById('course').value);
}
function test2(li) {
alert(li);
}
function findValue(li) {
alert(li.extra[0]);
if( li == null ) return alert("No match!");
// if coming from an AJAX call, let's use the CityId as the value
if( !!li.extra ) var sValue = li.extra[0];
// otherwise, let's just display the value in the text box
else var sValue = li.selectValue;
//alert("The value you selected was: " + sValue);
}
function selectItem(li) {
alert(li);
findValue(li);
}
</script>
</head>
<body>
<input type="text" name="course" id="course"/>
<input type="button" onclick="window.alert( $('#course').val() );" value="test" />
</body>
</html>