How about using document.write() to write the butotn dynamically into
the page. That is supported by all.

> -----Original Message-----
> From: Justin MacCarthy [mailto:[EMAIL PROTECTED]] 
> Sent: 14 January 2003 15:53
> To: [EMAIL PROTECTED]
> Subject: [ cf-dev ] ot-ish DOM question
> 
> 
> 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]
> 
> 



-- 
** 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