Jump to content
MakeWebGames

Recommended Posts

Posted

Some people have asked me this on msn.

What is Alternate Table Rows?

Alternate Tables Rows is like you have a diffrent color for each line of a table/tr *me thinks lol.

Example.

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Will out put

Hello. with the background color red.

Hello Again. with the background color blue.

How i do it is like.

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

How will i do this?

on your

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

stuff under it add

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

and then just edit the <tr> to like echo '<tr style="background-color: '. $bgcolor .'">';

I think i have shown what it does, i just wanted to post it because, its doing my head in on msn people asking how to do it lol.

Posted

Re: Alternate Table Rows

You can use jQuery for this:

#1 you render your HTML normally.

#2 you create some css:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

#3 you add some javascript:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Now all the tables of the class "zebra" will have alternating colors.

No need for anything in the PHP code for the display.

Posted

Re: Alternate Table Rows

 

You can use jQuery for this:

#1 you render your HTML normally.

#2 you create some css:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

#3 you add some javascript:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Now all the tables of the class "zebra" will have alternating colors.

No need for anything in the PHP code for the display.

I have neva used jQuery thanks :) for the tip also :D

Posted

Re: Alternate Table Rows

 

You can use jQuery for this:

#1 you render your HTML normally.

#2 you create some css:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

#3 you add some javascript:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Now all the tables of the class "zebra" will have alternating colors.

No need for anything in the PHP code for the display.

jQuery is a very good way of doing it

Posted

Re: Alternate Table Rows

another quick and easy method

.row-even{

background-color: #C0C0C0;

}

.row-odd{

background-color: #D8D8D8;

}

 

then before your where

$toggle = 1;

after

$toggle *= -1;

$style = $toggle < 0 ? 'row-even' : 'row-odd';

apply to the following

<tr class='$style' >

Posted

Re: Alternate Table Rows

 

another quick and easy method

.row-even{

background-color: #C0C0C0;

}

.row-odd{

background-color: #D8D8D8;

}

 

then before your where

$toggle = 1;

after

$toggle *= -1;

$style = $toggle < 0 ? 'row-even' : 'row-odd';

apply to the following

<tr class='$style' >

Ya or like my way but diff.

same css^^^

$style = ($style == "row-even") ? "row-odd" : "row-even";

<tr class="'. $style .'"> lol

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...