Problem with adding event handler by setAttribute

  • Thread starter Nonprofit Programmer
  • Start date
N

Nonprofit Programmer

I have the below code. I am trying to add the function chgDI() as the
handler for onChange event. However, the reference chgDI(newelement.value),
if
in parentheses, is not recognized as a function call. If parentheses are left
out, it is called only when the drawBOX function is called, and not when the
text area changes. Using addEvent results in a 'mismatch' error. Using
setAttribute doesn't work either. What can I do?

CODE within drawBOX() function:

newelement.attachEvent("change", chgDI(newelement.value));
-OR-
newelement.setAttribute("onChange" , "chgDI(newelement.value)");

I've tried both statements with and witout parentheses. No joy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top