Hello.
I'm trying to figure out why this isn't working...
<html><head><ti tle>Prob.11</title>
<script type="text/javascript">
function attachHandlers {
var the_opts=docume nt.getElementsB yTagName("input ");
for (var i=0; i<the_opts.leng th; i++) {
if ((the_opts[i].nodeName=="inp ut")||
(the_opts[i].nodeName=="INP UT"))
{
the_opts[i].onclick=change Background;
}
}
},
function changeBackgroun d(evt){
var purp_button = document.getEle mentById("first _button");
var yellow_button = document.getEle mentById("sec_b utton");
var pink_button = document.getEle mentById("third _button");
var black_button = document.getEle mentById("fourt h_button");
var the_body = document.getEle mentsByTagName( "body");
if (!evt)
{
evt = event;
this_sel = evt.srcElement;
}
else
{
this_sel = evt.target;
}
if (this_sel=purp_ button)
{
the_body.style. bgColor="purple ";
}
if (this_sel=yello w_button)
{
the_body.style. bgColor="yellow ";
}
if (this_sel=pink_ button)
{
the_body.style. bgColor="pink";
}
if (this_sel=black _button)
{
the_body.style. bgColor="black" ;
}
}
</script></head>
<body bgColor="blue" onLoad="attachH andlers();">
<div class="the_butt ons">
<input type="button" value="purple" id="first_butto n"><br>
<input type="button" value="yellow" id="sec_button" ><br>
<input type="button" value="pink" id="third_butto n"><br>
<input type="button" value="black" id="fourth_butt on">
</div>
</body>
</html>
--
Message posted via http://www.webmasterkb.com
I'm trying to figure out why this isn't working...
<html><head><ti tle>Prob.11</title>
<script type="text/javascript">
function attachHandlers {
var the_opts=docume nt.getElementsB yTagName("input ");
for (var i=0; i<the_opts.leng th; i++) {
if ((the_opts[i].nodeName=="inp ut")||
(the_opts[i].nodeName=="INP UT"))
{
the_opts[i].onclick=change Background;
}
}
},
function changeBackgroun d(evt){
var purp_button = document.getEle mentById("first _button");
var yellow_button = document.getEle mentById("sec_b utton");
var pink_button = document.getEle mentById("third _button");
var black_button = document.getEle mentById("fourt h_button");
var the_body = document.getEle mentsByTagName( "body");
if (!evt)
{
evt = event;
this_sel = evt.srcElement;
}
else
{
this_sel = evt.target;
}
if (this_sel=purp_ button)
{
the_body.style. bgColor="purple ";
}
if (this_sel=yello w_button)
{
the_body.style. bgColor="yellow ";
}
if (this_sel=pink_ button)
{
the_body.style. bgColor="pink";
}
if (this_sel=black _button)
{
the_body.style. bgColor="black" ;
}
}
</script></head>
<body bgColor="blue" onLoad="attachH andlers();">
<div class="the_butt ons">
<input type="button" value="purple" id="first_butto n"><br>
<input type="button" value="yellow" id="sec_button" ><br>
<input type="button" value="pink" id="third_butto n"><br>
<input type="button" value="black" id="fourth_butt on">
</div>
</body>
</html>
--
Message posted via http://www.webmasterkb.com
Comment