In comp.lang.javascript message <2d0fc7a0-2427-46e5-a637-e0e3ae10cf0e@j2
2g2000hsf.googlegroups.com>, Wed, 22 Oct 2008 08:06:38, laredotornado
Is there a way to trigger an event when the value of a hidden field
changes? At a certain point in time my hidden field is getting
changed to a value that I don't want but I can't find a place in the
code where this is happening by doing a search for its variable name.
You have tried in browsers other than IE? Error reporting is nicer in
Firefox. You have tried changing the name/ID of the hidden variable?
You have read the FAQ and asked yourself why you don't say what
browser(s) the problem occurs in?
You could edit your code for test so that the value of the hidden field,
before the unwanted change, its value is stored in a [global] variable.
Further edit to put, at the end of each existing code statement, pseudo-
code like
if hidden != saved than alert(<linenumber>)
That should enable you to find where the change occurs, which is a step
towards finding why.
If the error only occurs somewhere in the middle of user actions, then
you could use setInterval to check very frequently whether a change had
occurred; that might help in associating it with some input action and
hence some part of the code.
Learning and using a good debugger is a good idea; but, for a one-off,
the above may be quicker, especially if you have a script-editor which
can auto-insert the test in suitable locations.
It's a good idea to read the newsgroup c.l.j and its FAQ. See below.