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
    Regular Coder
    Join Date
    May 2004
    Posts
    391
    Thanks
    76
    Thanked 0 Times in 0 Posts

    disable onchange event

    How all.
    I have a field that has an onkeypress event that populates fields through an ajax script. The other fields that get populated have an onchange event so when they are populated with the ajax script the onchange event gets triggered which is not what I want. Is there anyway I can disable the onchange event while the onkeypress field is receiving input from the user?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,029
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    Looking at the below, it would appear that (in IE at least) onchange only fires when the data in the field is altered by the user, that is after the field receives focus.

    Code:
    <input type = "text" id = "txt1" size = "20" onchange = "a1()">
    <input type = "text" id = "txt2" size = "20" value = "Tracy" onchange = "alert ('Value of txt2 has changed')">
    
    <script type = "text/javascript">
    function a1() {
    document.getElementById("txt2").value = "Philip";
    }
    See also:-
    http://forums.devshed.com/javascript...ts-581334.html


    Edit: Tested in Firefox, same result.



    James (007) Bond: (to Bibi) You get your clothes back on, and I'll buy you an ice cream.
    Last edited by Philip M; 01-29-2009 at 05:06 PM.


  •  

    Posting Permissions

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