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

Thread: onChange

  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post

    onChange

    I have a onChange value
    Code:
       
    var people = [
            ["Timothy Conner", "1999-Present", "Age: 12", "Male", ""],
            ["Andrew Conner", "1992-Present", "Age: 19", "Male", ""]
        ];
    
    var how = "Brothers";
    
    function find()
    {
       if(document.getElementById("name").value == people [0] [0])
       {
          document.getElementById("desc").value = people [0] [1] + "   " + people [0] [2] + "   " +  people [0] [3];
       }
       if(document.getElementById("name").value == people [1] [0])
       {
         document.getElementById("desc").value = people [1] [1] + "   " + people [1] [2] + "   " +  people [1] [3];
       }
        document.getElementById("relateb").value = document.getElementById("name").value;
    }
    Code:
    Name: <input type="text" id="name" value="" onChange="find()"/>
    So for it to proses a name you must click out of a box is ther a way to make it instead of when you click out of it, it would immidiatly change?

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    966
    Thanks
    19
    Thanked 211 Times in 209 Posts
    To trigger events , either onblur
    or onchange you must give focus
    to something else or as you say
    "click out of it" Old Pedant has
    proposed another solution , you
    could periodically check the value
    with a setTimeout and respond if
    the value has changed.
    The usual way is to use keyup and
    keydown events (but these
    don't respond to pasted data)
    Last edited by DaveyErwin; 10-07-2011 at 01:53 AM.


  •  

    Posting Permissions

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