Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set all table rows to a colour.

Status
Not open for further replies.

bigozz

Programmer
Apr 12, 2001
39
GB
I am trying to change the background colour of all the rows in a table, I started out by using a for loop, but when there is a lot of data in the table it takes a shed load of time to complete.

Is there something like table.rows.all.bgcolor which I can set?

Thanks in advance
 
are you doing this dynamicly? if not
<style>
tr {background-color:#FF0000;}
</style>
<table>
<tr>
<td>
blah
</td>
</tr>
</table> You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
<script>
<!--
function change(){
for(i=0;i<table1.rows.length;i++){
table1.rows.style.background=&quot;black&quot;;
}
}
//-->
</script>
<body onLoad=&quot;change()&quot;>
<table id=&quot;table1&quot;>
<tr><td>a</td></tr>
<tr><td>s</td></tr>
<tr><td>d</td></tr>
</table>
</body>

Rick It's a pleasure to know that I've helped you. If I have,
please click the link below to let me know. :)
 
sorry. i forgot the part about no for loop.

Rick It's a pleasure to know that I've helped you. If I have,
please click the link below to let me know. :)
 
sorry, shouldn't have put those td's in there. try this for a example
<style>
tr {background-color:#FF0000;}
td {background-color:#808080;}
</style>


<table>
<tr>
blah
</tr>
<td>
blah
</td>
</table> You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
Don't know if this helps,

document.getElementById(&quot;table1&quot;).style.background=&quot;red&quot;


<table id=&quot;table1&quot;>
<tr>
<td></td>
</tr>
</table>


tsmith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top