Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use handleEvent()

Status
Not open for further replies.

forrozeiro

Programmer
Sep 1, 2001
38
0
0
BR
Hi,

I have a text input like this:

[input type=text name=a onChange=b()]

When I call document.forms[0].a.handleEvent('onChange') I get the error 'The object does not support this method or property' (or something like that).
What did I do wrong ?

Thank you in advance.
 
xutopia,

I am afraid that's not what I want. Rather than defining the event handler for the onChange event I would like to call the event handler already defined for that control.

Thanks anyway.
 
forrozeiro,

if you're already binding onchange to b() in the html tag, why do you need to do it again in script? you're wanting function b() to be called by form element "a" onchange, right?
 
jemminger,

That's because function b() is called only when the input's value is changed by the user. If the value is changed via code, b() is not called. See:

//this does not trigger a call to b() :
form.a.value = '1';
form.a.value = '2';

I´ve just found a solution. I just need to do this:

form.a.onchange();

That is because I am writing code that may change a field's value but doesn´t know which are the event handlers that must be called on the field being changed. In other words, I need a way to trigger the event handlers without having to know which they are. That is because the code I am writing will be a js utility library which can be used in several places.

Thank you and sorry by my English.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top