By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,848 Members | 3,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,848 IT Pros & Developers. It's quick & easy.

Possible to tell when a hidden field's value changes

P: n/a
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
Oct 22 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Oct 22, 8:06*pm, laredotornado <laredotorn...@zipmail.comwrote:
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

Oct 22 '08 #2

P: n/a
On Oct 22, 11:06*am, laredotornado <laredotorn...@zipmail.comwrote:
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.

Oct 22 '08 #3

P: n/a
In comp.lang.javascript message <2d0fc7a0-2427-46e5-a637-e0e3ae10cf0e@j2
2g2000hsf.googlegroups.com>, Wed, 22 Oct 2008 08:06:38, laredotornado
<la***********@zipmail.composted:
>
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.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE7 FF2 Op9 Sf3
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Oct 22 '08 #4

P: n/a
laredotornado wrote:
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
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Oct 22 '08 #5

P: n/a
laredotornado wrote:
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-Eve...mutationevents
[2] http://msdn.microsoft.com/en-us/libr...56(VS.85).aspx

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

--
comp.lang.javascript FAQ <URL: http://jibbering.com/faq/ >
Oct 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.