drawde83 wrote:
Hi,
I'm mocking up an interface in javascript for an HCI assignment. I want
to be able to make the default onclick event for the buttons on my page
to display an alert since the buttons won't work yet. Is there an easy
way to do this? and it has to be as easy as giving each button their
own onclick attribute otherwise I'll just do that.
Well, making it the default behavior is not too hard.
<html><head>
<script type="text/javascript" language="javascript1.2">
<!--
function myClick(oI)
{
alert("Under Construction " +oI.name)
}
function captureInputs()
{
aINPUTcollection=self.document.getElementsByTagNam e("input")
for(x=0;x<aINPUTcollection.length;x++)
{
oI=aINPUTcollection[x]
if(oI.type="button")if(!oI.onclick);
oI.onclick=new Function("return myClick(this)")
}
}
// -->
</script>
<body onload="captureInputs()">
<form name="foo">
<input type="button" name="foo1" value="foo1">
<input type="button" name="foo2" value="foo2">
<input type="button" name="foo3" value="foo2"
onclick="return false">
</form>
</body>
</html>
--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<> Internet Programming since 1994 <>=-- DHTML NSAPI TCP/IP
--=<>
http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<>
http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.