Does HTML Hidden control have any events? Like onchange or something?
Yes, certain browsers (such as Firefox) will fire an onclick
or onfocus
event on hidden elements when they're activated via an accesskey
attribute (meant to provide a keyboard hotkey to jump to an input).
Open the below in firefox, focus the frame, then strike Alt+Shift+x (Windows and Linux) or Ctrl+Alt+x (Mac).
<input type="hidden" accesskey="x" onclick="alert('clicked!');" />
Events are only triggered when the user performs the event in the browser, so if it's <input type="hidden">
or an <input>
hidden by CSS, the user won't be able to trigger events to your input.
The only way you would get onchange to work is if you manually trigger onchange in Javascript. A quick example of this:
<form name="f" onsubmit="document.f.h.value='1';
document.f.h.onchange();
return false;"
>
<input type="hidden" name="h" value="0" onchange="alert(document.f.h.value);" />
<input type="submit" />
</form>