...

View Full Version : disable onchange event



nikko50
01-29-2009, 03:27 PM
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?

Philip M
01-29-2009, 04:46 PM
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.



<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-development-115/disable-onchange-events-581334.html


Tested in Firefox, same result.


James (007) Bond: (to Bibi) You get your clothes back on, and I'll buy you an ice cream.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum