Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

How can I add a -id attribute to a perl cgi start_Tr ?

by misterperl (Pilgrim)
on Feb 27, 2015 at 15:28 UTC ( [id://1118081]=perlquestion: print w/replies, xml ) Need Help??

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

According to the CGI docs, the start_Tr tag generator is supposed to support *event* and *global* HTML attributes, as well as the 5-6 normal <tr> ones. One of the globals is id=. I tried
$cgi->start_Tr( -id => "thisID" )
and that yielded <tr> only- the attribute was ignored. Even common <tr> attributes aren't working like valign.
$cgi->start_Tr( -valign => "top" )
also yields simply <tr>.

Replies are listed 'Best First'.
Re: How can I add a -id attribute to a perl cgi start_Tr ?
by fishmonger (Chaplain) on Feb 27, 2015 at 15:35 UTC

    You need to pass the attributes as a hash ref

    print $cgi->start_Tr( {-id => "thisID", -valign => "top"} );
      thanks just saw that.. Working now :) Joy. Have a nice weekend..

        FWIW, I think is awkward usage and produces badly dated HTML.

        print $cgi->start_Tr({-id => "thisID", -valign => "top"});

        This is equivalent, less verbose, and less awkward–

        print '<tr id="thisID" valign="top">';

        I often use CGI to produce HTML but the strength lies in being able to tersely, e.g.–

        print table( Tr( td( \@long_list_of_td ) ) );

        So, for your use, I’d much rather inherit something like this–

        print Tr({-id => "thisID", -class => "CSSclass"}, td("some stuff"), td("etc") );

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found