Saturday, April 13, 2024
 Popular · Latest · Hot · Upcoming
150
rated 0 times [  155] [ 5]  / answers: 1 / hits: 52035  / 15 Years ago, tue, june 16, 2009, 12:00:00

Can I attach any event handlers to HTML hidden input fields? Basically I want to run a function when a hidden input field value changes.


More From » html

 Answers
34

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>




[#99301] Friday, June 12, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
madilynndiannac

Total Points: 191
Total Questions: 93
Total Answers: 111

Location: France
Member since Thu, Oct 15, 2020
4 Years ago
madilynndiannac questions
Sat, Aug 22, 20, 00:00, 4 Years ago
Tue, Jul 28, 20, 00:00, 4 Years ago
Thu, Jul 9, 20, 00:00, 4 Years ago
Mon, Jun 1, 20, 00:00, 4 Years ago
Mon, Jan 13, 20, 00:00, 4 Years ago
;