Hi guys

I got a DOM/JS/x-browser question. I have a function that adds a button to a
form using DOM.
 I also what to add a onclick event to the button to run a function...

here it is

<script>
function AddButton()
{
        var myinput= document.createElement("input");
        myinput.setAttribute("type","button");
        myinput.setAttribute("value","go");
        myinput.setAttribute("onclick",function () {alert('x')}); // line to
change

        document.getElementById("myform").appendChild(myinput);

}
</script>

now this version works in IE5+ but doesn't in mozilla. If I change the [line
to change ] above to

myinput.setAttribute("onclick","alert('whatever')"); // line to change

it works in mozilla.

Anyone know a x-platform way to add a javascript function the the onclick
event using DOM?
thanks
Justin


-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to