Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Help with CGI::WIDGET::TABS

by poj (Abbot)
on Aug 02, 2017 at 20:09 UTC ( [id://1196586]=note: print w/replies, xml ) Need Help??


in reply to Help with CGI::WIDGET::TABS

Not sure what you are expecting but try this

#!/usr/bin/perl use strict; use CGI::Widget::Tabs; use CGI; use DBI; use HTML::Template; my $cgi = CGI->new; my $tab = CGI::Widget::Tabs->new; $tab->cgi_object($cgi); $tab->headings( qw/Football Baseball/ ); $tab->wrap(3); $tab->default("Football"); my $heading = $tab->render; my $sql = q! SELECT team as TEAM, url as URL FROM sports WHERE sport = ? !; my $dbh = DBI->connect("dbi:Oracle:$dbname", $user, $passwd, {RaiseError => 1}) or die "Oracle Connect Failed: ", DBI->errstr; my $sth = $dbh->prepare($sql); $sth->execute($tab->active); my @rows; while (my @f = $sth->fetchrow_array) { push @rows, { TEAM => $f[0], URL => $f[1], }; } my $template = HTML::Template->new( filehandle => *DATA ); $template->param(TITLE=>"ENV Spreadsheet" ); $template->param(HEADINGS=>$heading, ROWS=>\@rows ); print "Content-Type: text/html\n\n",$template->output; __DATA__ <html> <title><TMPL_VAR name=TITLE></title> <style type="text/css"> table.tab { border-bottom: solid thin #C0D4E6; text-align: cente +r } td.tab { padding: 2 12 2 12; width: 80; background-color: #FA +FAD2 } td.tab_actv { padding: 2 12 2 12; width: 80; background-color: #C0 +D4E6 } td.tab_spc { width: 5 } td.tab_ind { width: 15 } </style> <body> <TMPL_VAR NAME=HEADINGS> <table border="1" cellpadding="5" cellspacing="0"> <TMPL_LOOP NAME=ROWS> <tr> <td><TMPL_VAR NAME=TEAM></td> <td><A HREF="<TMPL_VAR NAME=URL>" target="_blank"><TMPL_VAR NAME=UR +L></A></td> </tr> </TMPL_LOOP> </table> </body> </html>

Update : celpading corrected to cellpadding

poj

Replies are listed 'Best First'.
Re^2: Help with CGI::WIDGET::TABS
by dirtdog (Monk) on Aug 02, 2017 at 21:27 UTC

    thanks poj

    I'm getting HTML::Template::param() : attempt to set parameter 'headings' with a scalar - parameter is not a TMPL_VAR! at html.pl line 67

    Did you get yours to run?

      Yes mine runs, but notice I replaced this loop in your template

      <tr> <TMPL_LOOP NAME=HEADINGS> <th><TMPL_VAR NAME=HEADINGS></th> </TMPL_LOOP> </tr>

      with the single line

      <TMPL_VAR NAME=HEADINGS>
      poj

        That solved it poj. I think I'm real close to accomplishing the task of being able to click on each tab to go to a different page so to speak. However, I see the default tab of Football along with the corresponding URL's, but when I click on the BASEBALL Tab nothing happens

        Content-Type: text/html 'FOOTBALL' 'BASEBALL' Patriots http://www.patriots.com Bengals http://www.bengals.com Ravens http://www.ravens.com Steelers http://www.steelers.com

        Any idea what I could be missing?

        thanks again. I really appreciate your help

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1196586]
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-03-29 13:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found