quoclinh wrote:
Hi,
I'd like to create an input button with a click event calling a
javascript function. pretty basic. I just can't figure out how to
wire the onclick event. this is what I have so far:
function createButton(text, clickEvent)
{
var btn = document.createElement('input');
btn.type = 'submit';
btn.value = text;
//How to code click event here?
//How to set default css class?
return btn;
}
Your help is much appreciated.
Quoc Linh
Perhaps, something like this.
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>Test</TITLE>
<SCRIPT type="text/javascript">
function createButton(text)
{
var btn = document.createElement('input');
btn.setAttribute('type','submit');
btn.setAttribute('value',text);
var a = document.getElementById("test");
document.body.insertBefore( btn, a );
}
</SCRIPT>
</HEAD>
<BODY>
<A ID="test" HREF="#" ONCLICK="createButton('okay')">Click Me</A>
</BODY>
</HTML>
--
#
WWW.LOUDHEART.COM
# classified ad + forum
# = a work in progress