Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 22nd, 2010 | Syntax: None | Size: 1.54 KB | Hits: 54 | Expires: Never
Copy text to clipboard
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6.  
  7. <link rel="stylesheet" href="Autocompleter.css" type="text/css" media="screen">
  8.  
  9. <script type="text/javascript" src="jquery.js"></script>
  10. <script type='text/javascript' src='jquery.autocomplete.js'></script>
  11. <link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
  12.  
  13.  
  14. <script type="text/javascript">
  15. //$("#course").autocomplete().bind("autocompleteselect",fn);
  16.  
  17.  
  18. $().ready(function() {
  19.         $("#course").autocomplete("query_user.php", {
  20.                 width: 260,
  21.                 matchContains: true,
  22.                 scroll: true,
  23.                 onItemSelect:test2,
  24.                 selectFirst: false
  25.         });
  26.        
  27.        
  28. });
  29.  
  30. function test() {
  31.         alert(document.getElementById('course').value);
  32. }
  33.  
  34. function test2(li) {
  35. alert(li);
  36. }
  37. function findValue(li) {
  38.  
  39. alert(li.extra[0]);
  40. if( li == null ) return alert("No match!");
  41.  
  42. // if coming from an AJAX call, let's use the CityId as the value
  43. if( !!li.extra ) var sValue = li.extra[0];
  44.  
  45. // otherwise, let's just display the value in the text box
  46. else var sValue = li.selectValue;
  47.  
  48. //alert("The value you selected was: " + sValue);
  49. }
  50.  
  51. function selectItem(li) {
  52. alert(li);
  53. findValue(li);
  54. }
  55.  
  56.  
  57. </script>
  58.  
  59. </head>
  60.  
  61. <body>
  62.  
  63. <input type="text" name="course" id="course"/>
  64. <input type="button" onclick="window.alert( $('#course').val() );" value="test" />
  65. </body>
  66. </html>