DJRobThaMan
08-11-2003, 02:21 PM
What's up,
I'm trying to get this to work so that when you click on one div the text within it says "on" and the div that previously had "on" changes to "off".
If anybody can figure out where I went wrong that would be great.
<html>
<head>
<script type="text/JavaScript">
<!--
var i;
var j;
var k:
function tabs(i){
var thing = eval('document.getElementById(' + i + ').innerHTML');
thing = "on";
}
function lasttab(k){
var stuff = eval('document.getElementById(' + j + ').innerHTML');
j = 1;
while(j < 6){
if(stuff == "on"){
if(j == k){
}
else
{
stuff = "off";
}
}
++j;
}
}
-->
</script>
</head>
<body>
<div id="1" onClick="tabs(1);lasttab(1);" border=1 style="background-color:red;position:absolute;left:10;top:10;width:100;height:50;">
on
</div>
<div id="2" onClick="tabs(2);lasttab(2);" border=1 style="background-color:blue;position:absolute;left:110;top:10;width:100;height:50;">
off
</div>
<div id="3" onClick="tabs(3);lasttab(3);" border=1 style="background-color:red;position:absolute;left:210;top:10;width:100;height:50;">
off
</div>
<div id="4" onClick="tabs(4);lasttab(4);" border=1 style="background-color:blue;position:absolute;left:310;top:10;width:100;height:50;">
off
</div>
<div id="5" onClick="tabs(5);lasttab(5);" border=1 style="background-color:red;position:absolute;left:410;top:10;width:100;height:50;">
off
</div>
</body>
</html>
Thanks
I'm trying to get this to work so that when you click on one div the text within it says "on" and the div that previously had "on" changes to "off".
If anybody can figure out where I went wrong that would be great.
<html>
<head>
<script type="text/JavaScript">
<!--
var i;
var j;
var k:
function tabs(i){
var thing = eval('document.getElementById(' + i + ').innerHTML');
thing = "on";
}
function lasttab(k){
var stuff = eval('document.getElementById(' + j + ').innerHTML');
j = 1;
while(j < 6){
if(stuff == "on"){
if(j == k){
}
else
{
stuff = "off";
}
}
++j;
}
}
-->
</script>
</head>
<body>
<div id="1" onClick="tabs(1);lasttab(1);" border=1 style="background-color:red;position:absolute;left:10;top:10;width:100;height:50;">
on
</div>
<div id="2" onClick="tabs(2);lasttab(2);" border=1 style="background-color:blue;position:absolute;left:110;top:10;width:100;height:50;">
off
</div>
<div id="3" onClick="tabs(3);lasttab(3);" border=1 style="background-color:red;position:absolute;left:210;top:10;width:100;height:50;">
off
</div>
<div id="4" onClick="tabs(4);lasttab(4);" border=1 style="background-color:blue;position:absolute;left:310;top:10;width:100;height:50;">
off
</div>
<div id="5" onClick="tabs(5);lasttab(5);" border=1 style="background-color:red;position:absolute;left:410;top:10;width:100;height:50;">
off
</div>
</body>
</html>
Thanks