The onchange event in js is an event that is triggered when the value of an input control, such as a textbox, is changed on the client side. But if you change the value of a textbox in js code instead of changing the value of a textbox through keyboard input, the onchange event will not be triggered.
So, how to trigger the onchange event of the textbox control through code in js code mode? After consulting the information, I found that js provides a method that can trigger all events of the control. object.fireEvent() method, use methods such as object.fireEvent('onchange') to trigger the onchange event of the control.
In the same way, using the fireEvent method in js can also trigger other spatial events.
•To add , the above fireEvent method is not supported in Firefox browser. So, if you want to run it in both IE and FF, try the following code.
Copy the code code as follows:
if (obj.fireEvent)
{
obj.fireEvent('onchange');
}
else
{
obj.onchange();
}
That is to determine whether the fireEvent event is available. If not, use the onchange() method directly.