Possible to tell when a hidden field's value changes

L

laredotornado

Hi,

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.

Thanks, - Dave
 
S

sasuke

Hi,

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.

AFAIK, no, you can't trigger an event. A better way of finding the
rogue piece of code is to use a good tool like Firebug which allows
you to debug your Javascript app.

HTH,
/sasuke
 
D

Dr J R Stockton

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.
 
D

David Mark

Hi,

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
No.

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.

Search for what variable name? Sounds like you need to get acquainted
with your code.
 
T

Thomas 'PointedEars' Lahn

laredotornado said:
Is there a way to trigger an event when the value of a hidden field
changes?
Yes.

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.

A hidden field is no variable.


PointedEars
 
D

dhtml

laredotornado said:
Hi,

Is there a way to trigger an event when the value of a hidden field
changes?

It would be useful to have a reliable way to subscribe to property
change events. It wouldn't seem to
be the best way to debug your issue, though.

Mutation events are fickle, but you could try it out. Try setting a
mutation event for DOMAttrModified[1]. Make a simple testcase for it.

myInp.addEventListener("DOMAttrModified", function(ev) {
console.log(ev);
}, true);


For IE, use the developer toolbar. Or, you can also try using an -
onpropertychange - handler[2].

myInp.onpropertychange = function() {
alert(this.value);
}


[1]
http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-eventgroupings-mutationevents
[2] http://msdn.microsoft.com/en-us/library/ms536956(VS.85).aspx

At a certain point in time my hidden field is getting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top