CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
<TD width=33%> using CGI.pm?

 



vallely
Novice

Nov 16, 2001, 2:08 PM

Post #1 of 8 (1751 views)
<TD width=33%> using CGI.pm? Can't Post

I'm using CGI.pm to create a table.

push @rows, td [splice @items, 0, 3] while @items;
print table({-border=>undef,-width=>'75%'},Tr(\@rows));

Is it possible to specify bgcolor and width for the <td>?
I want the HTML output to be <td bgcolor=blue width=33%>.

Thanks in advance for any help.






pu_nk
journeyman

Nov 17, 2001, 6:24 AM

Post #2 of 8 (1744 views)
Re: <TD width=33%> using CGI.pm? [In reply to] Can't Post

Would this not work ?
print td(-bgcolor=>'blue', -width=>'33%');

I know you can add the Attributes -bgcolor and -width.
Give it a try.



Kanji
User / Moderator

Nov 17, 2001, 9:01 AM

Post #3 of 8 (1742 views)
Re: <TD width=33%> using CGI.pm? [In reply to] Can't Post

As with many of CGI methods, if you provide a hash reference of customized elements as the first argument ( method(\%hash, \@data) ), they'll be incorporated into that methods output ...


In Reply To

Code
push @rows, td( 
{ -bgcolor => 'blue', -width => '33%' },

[splice @items, 0, 3]
)
while @items;




vallely
Novice

Nov 17, 2001, 9:53 AM

Post #4 of 8 (1741 views)
Re: <TD width=33%> using CGI.pm? [In reply to] Can't Post

Thanks very much.
It was the placement of the <td> hash entries I was screwing up. I tried to add them to the
"print table" line.



clinton
Novice

Aug 17, 2005, 10:46 AM

Post #5 of 8 (1696 views)
Re: [vallely] <TD width=33%> using CGI.pm? [In reply to] Can't Post

Is it possible to specify attributes using the Tr(td[]) shortcut?

eg.

Code
<tr> 
<td bgcolor="black">Boo</td>
<td bgcolor="blue">Foo</td>
<td bgcolor="red">Coo</td>
</tr>


I know that you can do this in perl:

Code
print $web->Tr(td([Boo, Foo, Coo]));


But how would you add the attributes?

In Reply To



KevinR
Veteran


Aug 17, 2005, 2:44 PM

Post #6 of 8 (1695 views)
Re: [clinton] <TD width=33%> using CGI.pm? [In reply to] Can't Post

have you read the CGI.pm documentation?

http://perldoc.perl.org/CGI.html

print $web->Tr(td({-width=>'33%'},[Boo, Foo, Coo]));

PS: next time start a new thread, no need to drag up a 4 year old thread to ask a question. Wink
-------------------------------------------------


(This post was edited by KevinR on Aug 17, 2005, 2:46 PM)


clinton
Novice

Aug 17, 2005, 4:55 PM

Post #7 of 8 (1692 views)
Re: [KevinR] <TD width=33%> using CGI.pm? [In reply to] Can't Post

But I do not want everything to have a width of 33% (in your example).

As my example shows, I want specific attributes given to specific <td>'s, not blanket attributes to all <td>'s.

I have tried a few iterations of it but can't seem to figure it out. Just doing regular print statements may be the way to go.


KevinR
Veteran


Aug 18, 2005, 10:35 AM

Post #8 of 8 (1686 views)
Re: [clinton] <TD width=33%> using CGI.pm? [In reply to] Can't Post

I don't think you can. While CGI.pm can create a number of tags using a reference to a list (an array), it doesn't seem to be able to do the same thing with a reference to a list of attributes (a hash). You will need to create a seperate Td() function for each td tag that will have different attributes. Hopefully someone will correct me if I am wrong.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives