Forum Moderators: coopster

Message Too Old, No Replies

changing colour of table rows

         

bilenkyj

11:24 am on Mar 28, 2008 (gmt 0)

10+ Year Member



Hey all again,

I have a dynamic table - lots of rows that can change any time.
I would like to add a striped effect to the table but am a little unsure how to do it.

I have a counter so i was thinking would it be possible to have an if statements like this

if($counter==(A MULTIPLE OF 2)){Echo bgcolor="red";}else{echo bgcolor="blue";}

Is there a function that can check for this multiple of 2?
or is there a completely different way of doing this that any anyone is aware of?

thanks guys

scepanmali

11:38 am on Mar 28, 2008 (gmt 0)

10+ Year Member



Hi Bilenkyj,

Try to modify this code a little:

<tr onMouseOver="this.bgColor='#355466';" onMouseOut="this.bgColor='#2c4453';"> Just input your color :)

This will colorize the table and give it the selected row to change color! Hope I helped :)

bilenkyj

11:40 am on Mar 28, 2008 (gmt 0)

10+ Year Member



hey thanks for the reply,

I dont really want to have a mouseover function, i would like the stiping created when the table is first made not just when the mouse is hovered over

scepanmali

12:31 pm on Mar 28, 2008 (gmt 0)

10+ Year Member



Ok, if you don't need it, try this tutorial:
<snipped url>
no blogs please, authoritative site links only
(php.net, mysql.com, etc.)

[edited by: coopster at 7:11 pm (utc) on Mar. 28, 2008]
[edit reason] removed url [/edit]

bilenkyj

12:34 pm on Mar 28, 2008 (gmt 0)

10+ Year Member



funnily enough thats where i've just been and have put it into place, works well

thanks

penders

1:26 pm on Mar 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



try this tutorial...

Just a thought... the tutorial discusses the principle of using the modulus operator (%) to find the remainder when dividing by 2 (to find odd and even rows). Fine. However it also talks about using the deprecated bgcolor attribute to hard code the colour on the element. Not so good. It would perhaps be better to assign a class instead which defines the background-color in your stylesheet.