Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2011
    Posts
    60
    Thanks
    1
    Thanked 0 Times in 0 Posts

    jquery grab stuff when keydown

    So.... it doesn't work

    HTML

    Code:
    <html> <head>
     <script type="text/JavaScript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"> </script>
    <script type="text/JavaScript">
    //<![CDATA[
    
    $(document).ready(function() {
       $(".encode").keydown(function() {
    		setTimeout(function() {
    								 
    			  /* get some values from elements on the page: */
    			  var $form = bigform,
    				  term = $form.find( 'input[name="encode"]' ).val(),
    				  url = 'encode.php';
    			 
    			  /* Send the data using post */
    			  var posting = $.post( url, { s: term } );
    			 
    			  /* Put the results in a div */
    			  posting.done(function( data ) {
    				var content = $( data ).find( '#content' );
    				$( "#textbox" ).empty().append( content );
    			  });}, 50)
    			});
       });
    //]]>
    </SCRIPT>
    
    </head>
    <body>
    
    <form action="" method="POST" name="bigform">
    <input type="text" name="encode">
    
    </form>
    <div id="textbox"> </div>
    </body>
    </html>
    PHP


  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,026
    Thanks
    23
    Thanked 588 Times in 587 Posts
    $(".encode").keydown(function() {

    and

    <input type="text" name="encode">

    don't work. class="encode" would help, same with bigform but What are you trying to do? It might be better to get the input tag contents on blur.
    Last edited by sunfighter; 05-01-2013 at 08:44 PM.
    Evolution - The non-random survival of random variants.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •