Gossamer Forum
Home : Products : DBMan : Customization :

Alternating table rows using short/long mod

Quote Reply
Alternating table rows using short/long mod
I have JPDeni's short/long record mod to DBMan installed, and I've modified html.pl quite a bit, but it's working fine (default database is at http://www.bigday.tv/scripts/db.cgi?db_default). Now, though, I want more than one line of info displayed in each short record, which takes up a single table row in the HTML generated by sub html_record in subs html_view_success, html_delete_form, and html_modify_form. So I want the alternating rows starting with the second table cell from the left to be different colors -- i.e., starting with the second table cell, the row for the first record is green (#F0FFF0), the next record (row down) white, the third green, the fourth white, etc.

I've been working on this for six hours, but I'm really lame at Perl and can't get it right. What I've done is only manage to change all the rows one color or the other. I'm pretty sure the solution involves creating an array with a looping routine within either html_record or the other subs.

Here's what I have so far (wincing from embarrassment):

In sub html_view_success (and similarly in sub html_delete_form, and sub html_modify_form),
tried this in the rec_count loop (red is new):

$rec_count = 1;
$odd = "#F0FFF0";
$even = "#FFFFFF";
$bgcol = $even;
@bgcols = [0];


print qq|
<table width="758" cellpadding="7" cellspacing="0" border="0">
<tr>
<td><img src="/images/shim.gif" width="1" height="1" vspace="0" hspace="68" border="0"></td>
<td><img src="/images/shim.gif" width="1" height="1" vspace="0" hspace="296" border="0"></td>

</tr> |;

for (0 .. $numhits - 1) {
if ($bgcol==$even) { #if the last row was honeydew
$bgcol=$odd #make the next one white
} else { #if the last one was white
$bgcol=$even #make the next one honeydew
}
push(@bgcols,$bgcol);

print qq|
<tr>
<td> </td>|;
&html_record (&array_to_hash($_, @hits, @bgcols));
print "</tr>";
++$rec_count;
}

In sub html_record, changed 'print "<td>" to this:

print "<td bgcolor=$bgcol>";

ANY help is welcome. TIA!

William


William Hillis
4411 Governor Ln SE
Olympia, WA 98501
email: w.hillis@worldnet.att.net
Quote Reply
Re: Alternating table rows using short/long mod In reply to
You may want to check out the FAQ noted below under the section "Viewing". You will find thread references there for using Alternating colors and examples of how to setup and use an array.

You might also want to consider keeping your table width at about 600 max. This will make your output viewable in most browsers without having to scroll across a page. This would include those using browsers such as webtv would have a very limited viewing area Smile

Hope this helps

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Alternating table rows using short/long mod In reply to
Perfect! Just what I needed. Sorry I missed that item in the FAQ. Thanks so much for your help.

About the screen-width: it was a difficult choice, but I decided to target 800X600 and above simply because it's too much of a hassle to continue supporting 640X480 and WebTV. They represent too small a proportion of my target audience relative to the accommodations they require.

William

William Hillis
4411 Governor Ln SE
Olympia, WA 98501
email: w.hillis@worldnet.att.net
Quote Reply
Re: Alternating table rows using short/long mod In reply to
I have tried what the FAQ screen told me, but I must have done something wrong, since it is not working. The coding seems fairly simple, but I am not an expert at this at all. We are using the short/long mod, and would like the rows to alternate colors. The address to the .pl that I have tried to manipulate is http://agecon.tamu.edu/...business/agbuspl.txt
The address to a version that I have not tried it on is
http://agecon.tamu.edu/...iness/agbusplbku.txt

Please take a look at the .pl, and offer any guidence that you might have. Here is my .cfg also.
http://agecon.tamu.edu/...usiness/agbuscfg.txt

Thanks for your help.
Please let me know what needs to be done.

Thanks,
cwhatley

Quote Reply
Re: Alternating table rows using short/long mod In reply to
Ok. I got it working. It's amazing what you learn as you try to diagnose problems. It was an HTML error as the html_record data was passed to the html_view_success form. I was ending up with extra <td>, <tr> and <table> codes on my webpage. I just eliminated these codes in html_record until the problem went away and the output was a single table that had a header and alternating colors on each row of the data.

Thanks,
cwhatley