Michael Bar-David wrote:

I'm trying to dynamically add buttons to the page, and giving them numbers: when clicking button1 it should use a function, and give it 1 as parameter, the second is button2, an should pass 2 as parameter, and so on.
this code make problems (I can't define what):

button.addEventListener('click', function (){ foo(ixyzt)}, 'false');
ixyzt++;

(ixyzt is a global variable)

Another approach that Gecko supports is to use a handler object:
function fooListener(arg) {
   this.arg = arg;
}
fooListener.prototype.handleEvent = function handleEvent(event) {
   foo(this.arg);
}
button.addEventListener('click', new fooListener(ixyzt++), false);
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners

Reply via email to