in reply to Re^4: Help with CGI::WIDGET::TABS
in thread Help with CGI::WIDGET::TABS

If you look at the page source you should see something like this

<!-- Generated by CGI::Widget::Tabs v1.14 --> <table class="tab"> <tr> <td class="tab_spc"></td> <td class="tab"><a href="?tab=Football">Football</a></td><td class="ta +b_spc"></td> <td class="tab_actv"><a href="?tab=Baseball">Baseball</a></td><td clas +s="tab_spc"></td> </tr> </table> <!-- End CGI::Widget::Tabs v1.14 -->
poj

Replies are listed 'Best First'.
Re^6: Help with CGI::WIDGET::TABS
by dirtdog (Monk) on Aug 03, 2017 at 17:36 UTC

    I have something similar to you:

    <!-- Generated by CGI::Widget::Tabs v1.14 --> <table class="tab"> <tr> <td class="tab_spc"></td> <td class="tab"><a href="?tab=%26%2339%3BPROD_RTP%26%2339%3B">&#39;PRO +D_RTP&#39;</a></td><td class="tab_spc"></td> <td class="tab"><a href="?tab=%26%2339%3BPROD_OMA%26%2339%3B">&#39;PRO +D_OMA&#39;</a></td><td class="tab_spc"></td> </tr> </table>

    Using my business example, One thing I notice is that I don't have the "tab_actv" like you do. Also, for my underlying html data that each tab would reference, I'm only getting the ROW data for my first tab (PROD_RTP). Wouldn't I need a loop of some sort to generate the sql results from all the headings? The code below only prints the html from the results of the value from $tab->active, which in my case is whatever is assigned as default...for example: $tab->default("PROD_RTP"). If I expand the webpage to include several more tabs, how does the database handle statement (my $sth = $dbh->prepar($sql)) execute each query to render the html? Just seems like I need a loop.

    my $sth = $dbh->prepare($sql); $sth->execute($tab->active); my @rows; while (my @f = $sth->fetchrow_array) { push @rows, { CLIENT => $f[0], URL => $f[1], }; } my $script="$ENV{'HOME'}/scripts/template.pl"; my $template = HTML::Template->new(filename => $script); $template->param(TITLE=>'ENV Spreadsheet'); $template->param(HEADINGS=>$heading, ROWS=>\@rows );

    In the hypothetical Football and Baseball example, the rest of the html output would have the ROW data for Teams and their associated URL. When you click on the Baseball Tab, How does the Baseball tab know that the Baseball teams and baseball team URLS belong to said tab?

    Thanks for your time poj.

      How are you creating the headings here, $tab->headings( ??? ) ?

      they appear to have single quotes ' (html encoded as &#39;) around them

        yes. I had them in single quotes. doh!

        <!-- Generated by CGI::Widget::Tabs v1.14 --> <table class="tab"> <tr> <td class="tab_spc"></td> <td class="tab_actv"><a href="?tab=PROD_RTP">PROD_RTP</a></td><td clas +s="tab_spc"></td> <td class="tab"><a href="?tab=PROD_OMA">PROD_OMA</a></td><td class="ta +b_spc"></td> </tr> </table> <!-- End CGI::Widget::Tabs v1.14 -->

        Looks better now. Do you have any thoughts on the 2nd part of my last question? About if I need a loop to make sure each sql is executed and associated with the appropriate tab?