4

I want to add a function to OnChange event of textbox at runtime (on page load). But if there is already a function define at onchange event of the particular textbox then I need to make sure the both function get a call at onchange event. How can I achieve that? I am using IE7.

1 Answer 1

4

You can use the addEventListener function on that textbox

  var tb = document.getElementById("textbox");
  tb.addEventListener("change", function(evt) {
    alert(tb.value);
  }, false);

But for older versions of IE (IE6), this will not work. For that you can use the addEvent

Sign up to request clarification or add additional context in comments.

1 Comment

addEventListener has a third argument which is only optional in recent browser (since FF 6). You should provide that parameter for broadest compatibility. That argument determines whether to capture (true) the event or to let it propagate upward (false). Check out the function reference at developer.mozilla.org/en/DOM/element.addEventListener

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.