Monday, February 15, 2010

PERL Trick to Make Alternative Row Color

The mod or modular operator in PERL (%) is responsible for this trick.

The following codes show how I did it:


.
.
.
$total_hits++;

if ($total_hits % 2) { $rowcolor = " bgcolor=#FFEEEE"; }
else { $rowcolor = " bgcolor=#FFFFFF"; }
.
.
.


These codes are in a loop to list out all the items. You can place the $rowcolor in the <TR> tag. The rows displayed will be in pink and white alternatively.

No comments:

Post a Comment