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 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    95
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Event function tutorials.

    I've tried looking for tutorials on how to make a function that executes every time a specific event happens, (see below for an example) but I can't quite find the correct wording to find a tutorial that would show me how these really work. I want to do something like this that would execute every time a key is pressed on an input field. Anyone understand what I want enough to know of a site that will help me with this?

    Example:

    Code:
    xhr.onReadyStateChange  = function() { 
        CODE HERE
    };

  • #2
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    For everytime a key is hit would look something like this

    Code:
    <input type="text" id="t" name="t" />
    
    <script type="text/javascript">
    document.getElementById("t").onkeypress = function () {
      alert("a key was hit");
    };
    </script>
    david_kw

  • #3
    Regular Coder
    Join Date
    Oct 2006
    Posts
    206
    Thanks
    1
    Thanked 0 Times in 0 Posts

  • #4
    New Coder
    Join Date
    Dec 2006
    Posts
    95
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by david_kw View Post
    For everytime a key is hit would look something like this

    Code:
    <input type="text" id="t" name="t" />
    
    <script type="text/javascript">
    document.getElementById("t").onkeypress = function () {
      alert("a key was hit");
    };
    </script>
    david_kw
    Thanks. See, I tried that in my code before I asked and it didn't work, which means I had something wrong with the other part of my code for it so now I know which part of it made it not work.


  •  

    Posting Permissions

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