Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

CGI Table?

by JimJx (Beadle)
on Oct 12, 2007 at 06:36 UTC ( [id://644389]=perlquestion: print w/replies, xml ) Need Help??

JimJx has asked for the wisdom of the Perl Monks concerning the following question:

I have a script that uses
push (@rows, Tr (td (\@cells),(td (\@cells2)))); $page .= table ({-border => 3, width=> 550}, @rows) . br ( );
And now for the stupidest question of the night, how do I fix the width of the TD? And while I am at it, is there a CGI guide somewhere that will help me?

Thanks in advance,
Jim

Replies are listed 'Best First'.
Re: CGI Table?
by CountZero (Bishop) on Oct 12, 2007 at 08:00 UTC
    A --probably-- unhelpful answer: in general one should avoid fixing lengths and widths of HTML tables and cells. It is the whole idea and philospohy behind HTML that the client's browser takes care of the rendering and adjusts it as necessary taking into account the screen-size, output media, ...

    At the most one should give some hints to the browser by using CSS, but that should be about it.

    But to answer your question (and assuming you use CGI), you will read in the docs:

    If the first argument is an associative array reference, then the keys and values of the associative array become the HTML tag's attributes
    The HTML 4.01 docs state that table cells take an attribute of width = length but that it is deprecated (in favour of putting it in CSS of course).

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      WOW!!!

      Thanks for answering everyone, really shows what support is available for PERL users (even a novice such as myself.....)

Re: CGI Table?
by atemon (Chaplain) on Oct 12, 2007 at 07:50 UTC

    Hi,

    I hope you are looking for CGI from CPAN.

    Now answer to your question.
    you can pass a hash {width=>'20px'} to each call to td so that those attributes will be in the generated TD tags.

    push (@rows, Tr (td ({width=>'20px'},\@cells),(td ( {width=>'20px'},\@ +cells2)))); print $q->table ({-border => 3, width=> 550}, @rows) . br ( );

    Cheers !

    --VC



    There are three sides to any argument.....
    your side, my side and the right side.

Re: CGI Table?
by aku (Monk) on Oct 12, 2007 at 07:50 UTC
    You can give width to TD like this (added to your example):
    push (@rows, Tr (td ({-width => 50}, \@cells),(td ({-width => 100}, \@ +cells2))));
    Or maybe you want to use style or class tag with some css. Then use -style or -class.

    See CGI-modules documentation: CGI

Re: CGI Table?
by Krambambuli (Curate) on Oct 12, 2007 at 07:55 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://644389]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-29 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found