Q
quoclinh
Hi,
I have the following function that works. It would create an input
that would invoke a click event that call a javascript function:
function createButton(text)
{
var btn = document.createElement('input');
btn.type = 'submit';
btn.value = text;
btn.setAttribute('onclick', 'execAction()'); //this does not
work
btn.setAttribute('class', 'CustomButton'); //this does not
work
btn.onclick = execAction; //this works
return btn;
}
function execAction()
{
alert('in execAction');
return false;
}
The question is, if I have an execAction function with an argument,
how do I change the code in createButton to accomodate it?
Thanks in advance,
Quoc Linh
I have the following function that works. It would create an input
that would invoke a click event that call a javascript function:
function createButton(text)
{
var btn = document.createElement('input');
btn.type = 'submit';
btn.value = text;
btn.setAttribute('onclick', 'execAction()'); //this does not
work
btn.setAttribute('class', 'CustomButton'); //this does not
work
btn.onclick = execAction; //this works
return btn;
}
function execAction()
{
alert('in execAction');
return false;
}
The question is, if I have an execAction function with an argument,
how do I change the code in createButton to accomodate it?
Thanks in advance,
Quoc Linh