How can I get it so that every other table or table row be a different color like the ones in this forum? If I didn't explain this problem well enough just ask, in the past I have had problems stating what I need....
Well, I'm not a CSS master or anything, but I don't think you can do it without some sort of HTML embedded programming language like PHP or Javascript.
Otherwise you'll have to create each table entry by hand, and modify the background color yourself as you create each row.
If you're reading from a database, it would be simple enough to output your rows into a table using PHP, generating a new background color for each row.
What are you going to be doing with the table? Are you building the rows by hand or are you compiling the table from a script?
You can create css classes and assign properties to those classes.
For Example:
Put something like this in your Header:
<style type="text/css">
<!--
.class1 {
background-color: blue;
color: white;
}
.class2 {
background-color: green;
color: black;
}
-->
</style>
Then assign the class to your table rows:
<table>
<tr class="class1"><TD>DATA</td><td>more data</td></tr>
<tr class="class2"><TD>DATA</td><td>more data</td></tr>
<tr class="class1"><TD>DATA</td><td>more data</td></tr>
</table>
Ahhh... I did explain it wrong. I already know how to do assign classes to different things, but what I'm wanting to do is have it automatically place 2 different colors one right after the other like this forum. Example:
kasuals: I am creating the table from a script, placing a record in each one. I only want two different colors, I already know those colors and I want to be able to have each table have one of those colors. Look at the example I did in my other reply please. Thanks anyway.
Kasuals: I dont know if you missed my earlier post, but I already answered your question right before you replied. Check back it should be one post before your last reply, thanks.
Well, I dont know asp. However in most of the C based languages, I would do the following:
(I always have TRUE and FALSE defined as 1 and 0, just to make things easier on myself. You can use anything technically. This example is in PHP.)
/*Within your loop for reading from the rows in the DB*/
$switch_color = FALSE;
/*Check to see if we need to switch colors*/
switch($switch_color) {
case FALSE:
printf("<tr class='class1'>\n"
printf("<td>Blah blah.</td>\n"
printf("</tr>\n"
$switch_color = TRUE;
break;
case TRUE:
printf("<tr class='class2'>\n"
printf("<td>Blah blah.</td>\n"
printf("</tr>\n"
$switch_color = FALSE;
break;
default:
printf("<tr class='class1'>\n"
printf("<td>Blah blah.</td>\n"
printf("</tr>\n"
$switch_color = TRUE;
break;
}
I'm not sure how familiar you are with C based languages, but if ASP is anything like them, then you should understand that. If not... then I don't know how else to help you.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.