Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: cange bgcolor of TD


Message #1 by Dimitriy Dribinskiy <DimitriyD@M...> on Mon, 21 May 2001 16:22:58 -0400


Hi,
try this

<html>
<head>
<SCRIPT>
NumberOfRows=10;
NumberOfColumns=2;
function testColor(s)
{
     eval('document.form1.TR' + s + '.style.BGCOLOR = "#CCCCCC"')
}
</SCRIPT>
</HEAD>
<BODY>
<form id=form1 name=form1>
     <TABLE bgcolor="#000000" cellpadding="0" cellspacing="0" border="0"
width="400" >
          <TR><TD>
               <TABLE bgcolor="#000000" border="0" cellpadding="1"
cellspacing="1" width="400">
                    <SCRIPT>
                    var istring='';
                    var TestString='';
                    for(i=0; i < NumberOfRows; i++)
                    {
                         istring = "<TR id=TR" + [ i ] + "onClick=testColor(" +
[ i ] + ")>";

                         for(l=0; l < NumberOfColumns; l++)
                              istring = istring+"<TD row"+ [i+1]+"column" +
[l+1] + "> "+";"+"</TD>";
                              istring = istring + "</TR>";
                              TestString = TestString + istring;
                    }
                    document.writeln(TestString);
                    </SCRIPT>
               </TABLE>
          </TD></TR>
     </TABLE>
</form>
</BODY>
</html>



Hope this helps

Vinay Poddar

Tata Consultancy Services
STP, Malad
Mumbai 400097
Ph (022)8774081 extn 292/289



  Return to Index