minil minil - 4 months ago 18
Javascript Question

How to pass parameter to the attachEvent javascript function

I have to pass paramter the validateNum javascript function (eg. num1, num2)

if (num1.attachEvent) {
num1.attachEvent("onkeypress", validateNum);
}


How to pass. can i get code sample?

Answer

You need to make an anonymous currier:

num1.attachEvent("onkeypress", function() { return validateNum(num1, num2); });  
Comments