Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What event can be captured when an HTML hidden input value is set / changed

HI, In JavaScript when value is set to a hidden input control, which event is fired?

like image 207
user239635 Avatar asked Jan 08 '10 09:01

user239635


People also ask

What is the use of input type hidden in HTML?

Definition and Usage The <input type="hidden"> defines a hidden input field. A hidden field lets web developers include data that cannot be seen or modified by users when a form is submitted. A hidden field often stores what database record that needs to be updated when the form is submitted.

Which event is triggered when a form field is changed?

Whenever the value of a form field changes, it fires a "change" event.

Which input event will you use on an input tag to get notified every time a user changes something?

The oninput event occurs when an element gets user input. This event occurs when the value of an <input> or <textarea> element is changed.

Which of the following events is generated when the value of textfield or textarea is change?

The input event fires when the value of an <input> , <select> , or <textarea> element has been changed.


1 Answers

Whenever you change the value of a hidden field using script, it wont fire any event. But you can manually trigger the event if you are using jQuery.

Lets assume that you have the following hidden field

<input type="hidden" id="hid" value="0" 
onchange="alert('Caught the hidden event');" />

When you change the value of the field using following code, it will not display the alert message.

$("#hid").val("2");

But you can trigger the change event using the following code

$("#hid").val("2").change();

Above code will display the alert message.

like image 80
Elangovan Avatar answered Sep 18 '22 10:09

Elangovan