Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with onchange in IE 5

Status
Not open for further replies.

lpatnaik

Programmer
Jul 11, 2002
53
0
0
Hi,

I have a textbox in a page. I want to track the onchange events and populate a global variable. But in IE 5 I am facing some problem. The event doesnt fire. I have no idea about the solution. Could anyone help me out.

Also i cannot use the onblur event (which seems to be working fine) as only if there is some editing done that the variable needs to be populated. Hope I am being clear enough.
 
As far a I know, the onChange event does not work with textboxes, try the onKeyPress event. I actually use the onBlur event to detect changes (I store the oeiginal data in an array and check the new data against the data in that array). Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
It's sad that some Americans proudly turn their backs on the very Flag the gives them the opportunity to do just that... - Mike
 
But this does not sound feasible when you have a whole lot of items in the page. I could use the onKeyPress event but what if the user copies and pastes something on the textbox using his mouse.

Please reply asap
 
I actually use it on database loaded forms with about 120 fields...

What I do is load the current field values into an array onLoad, then onBlur I check the entered value vs the stored value...

<script>
var allFields = new Array()
function loadArr(){
for (x=0; x<document.myForm.elements.length; x==){
allFields[x] = document.myForm.elements[x].value
}
}
function checkForChanges(){
for (x=0; x<document.myForm.elements.length; x==){
if (document.myForm.elements[x].value != allFields[x]){
alert(&quot;Field changed&quot;)
}
}
}
</script>

<body onLoad=&quot;loadArr()&quot;>
<form name=&quot;myForm&quot;>
<input name=&quot;someInput&quot; onBlur=&quot;checkForChanges()&quot;>
</form> Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
It's sad that some Americans proudly turn their backs on the very Flag the gives them the opportunity to do just that... - Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top