...

View Full Version : OnChangeEvent of Textbox is not firing in IE but fires in Opera



thirudotnet
01-21-2006, 07:01 AM
Onchange event of textbox is not firing in IE under this condition but fires in Opera.

Condition:
After changing the value, in the tab key press again i'm changing the value dynamically at this time the onchange event is not firing. But it works fine in Opera. Have a look at the code.
--------------------------------------------------------------------------
<html>
<head>
</head>
<body>
<form>
<input type="text" name="1" id="1" onkeydown="one_onkd();" onchange="txt_onchange();"><input type="text" name="2" id="2" onchange="txt_onchange();">
</form>
</body>
<script>
function one_onkd()
{
if (event.keyCode==9)
{
document.getElementById("1").value="newvalue";
}
}
function txt_onchange()
{
alert("On Change event of " + event.srcElement.id);
}
</script>
</html>
--------------------------------------------------------------------------

Kor
01-21-2006, 10:40 AM
onchange will not fire the function until the field loses it's focus (onblur), this is the reson for usually it is better to use unkeyup instead of onchange in case of text fields or textareas.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum