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 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2005
    Posts
    25
    Thanks
    2
    Thanked 0 Times in 0 Posts

    jquery reading input value

    Code:
      <script type="text/javascript">
    	$(document).ready(function(){
    		var __checkKey = null;
    			$('#SearchAll').keypress(function(e){
    				__checkKey = e.keyCode;
    				__value = $(this).val();
    				console.log(__value);
    			})
    	});
      </script>
    i have an input box that would like to read the value of it whenever the user types something

    the problem with the above code for example if i type

    abc it will read ab
    if i add d to abc to become abcd it will only read abc!
    its driving me crazy any ideas???

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Use keyup instead:
    Code:
    $('#SearchAll').keypress(function(e){
    Hope that helps.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #3
    New Coder
    Join Date
    Nov 2005
    Posts
    25
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thank you very much it worked!!!


  •  

    Tags for this Thread

    Posting Permissions

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