Advertisement
Guest User

onKeyUpHandler

a guest
Jan 22nd, 2015
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.34 KB | None | 0 0
  1. <html>
  2.  <head>
  3.   <style type="text/css">
  4.     #abc{ boarder:1px solid black; width: 500px; height: 40px;}
  5.   </style>
  6.  <script type="text/javascript">
  7.  function onKeyUpHandler(campo, funcao, tempo,paramentro)
  8. {
  9.    var searchTimeout;
  10.    campo.onkeyup = function (event)
  11.    {
  12.       var tecla = (window.Event) ? event.which : event.charCode;
  13.       if (typeof searchTimeout != "undefined") clearTimeout(searchTimeout);
  14.       if (typeof paramentro == "undefined") paramentro = "";
  15.       else{var string = new String(paramentro);
  16.       if (string.substr(0,1)!=',') paramentro = ",'"+paramentro+"'"; }
  17.       searchTimeout = setTimeout(funcao+"("+campo.id+","+tecla+paramentro+")", tempo);
  18.   };
  19. }
  20.  function funcaoteste(nomecampo, teclapress)
  21.  {
  22.         document.getElementById('def').innerHTML += nomecampo+'|'+teclapress+'<br />';
  23.         document.getElementById('def2').innerHTML += nomecampo.value+'<br />';
  24.  }
  25.  function criaInput()
  26.  {
  27.       document.getElementById('abc').innerHTML = '<input type="text" name="idteste" id="idteste" value=""  onfocus="if (this.onkeyup==null) onKeyUpHandler(this,\'funcaoteste\',1000);"  />';
  28.  }
  29.  </script>
  30.  </head>
  31.  <body>
  32.    <div id="abc"></div>
  33.    <div id="def"></div>
  34.    <div id="def2"></div>
  35.    <div id="ghi">
  36.      <input type="button" value="Novo Input" onclick="criaInput();"/>
  37.    </div>
  38.  </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement