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

hi , i have a perl script which generates three result arrays after searching through some text documents. Now, i need to display these results on three different tabs , one for each array . A fourth tab to summarise the search results . How can i generate such an interface from my script itself?? Of course , a search form would be part of this interface so that the user can search again. can anybody direct me towards how to approach this problem??

Replies are listed 'Best First'.
Re: Tabbed html interfaces using perl??
by tachyon (Chancellor) on Oct 21, 2004 at 06:20 UTC

    It sounds like you don't quite know how to maintain state yet. Here is a very basic example for you that uses a dispatch table of sorts. The actions are typically references to functions so that the script does different stuff for each action.

    #!/usr/bin/perl -w use strict; use CGI; my $q = new CGI; print $q->header; my $script = '/cgi-bin/tabs.pl'; my %actions = ( tab1 => 'This is tab 1', tab2 => 'This is tab 2', tab3 => 'This is tab 3', summary => 'Summary', search => 'Search page', ); my @tab_order = qw ( search tab1 tab2 tab3 summary ); my $action = $q->param('action') || 'search'; $action = 'search' unless exists $actions{$action}; display($action); exit 0; sub display { my $action = shift; my @tabs = map{ $action eq $_ ? "[$action]" : make_link($_) } @tab +_order; my $html = "<p>@tabs<hr><p>$actions{$action}"; print $html; } sub make_link { qq!<a href="$script?action=$_[0]">$_[0]</a>! }

    cheers

    tachyon

Re: Tabbed html interfaces using perl??
by pernod (Chaplain) on Oct 21, 2004 at 06:21 UTC

    Or you could read up on CGI::Widget::Tabs, which will probably take you part of the way. We're experimenting with this module here at $firm, and it seems to work just fine.

    Have a nice day.

    pernod
    --
    Mischief. Mayhem. Soap.

Re: Tabbed html interfaces using perl??
by Anonymous Monk on Oct 21, 2004 at 05:03 UTC
    What do you have so far and which part are you having trouble with?
      so far i have a template of the html page i want to display. the way i have set it up is that , its not tabs actually, but just gif images which give the look of tabs , but are essentially linked to another html page. so what i have is four different html pages for displaying the four arrays.

        The only portion of your question that relates to Perl can be answered by saying, "Use print to output whatever HTML you wish for your script to produce."

        What HTML (and Javascript) is needed to produce the look you're after on your website is... an HTML / Javascript question, and should be posed to an HTML or Javascript forum.

        As an aside, if you're struggling with CGI in general, pick up the book, "CGI Programming with Perl". If you're unfamiliar with Perl, start with "Learning Perl" first, or the CGI book will lose you quickly. Both of those books are published by O'Reilly & Associates. It will also prove beneficial (if not crucial) to read the documentation for CGI.


        Dave

Re: Tabbed html interfaces using perl??
by Anonymous Monk on Oct 21, 2004 at 05:03 UTC
    html does not have tabs
        The hell you say, those are lists, not tabs.

      True, but then computers do not have tabs either. File folders have tabs, some books have tabs, soda cans have tabs (of a different kind), but not computers. Computers only have a tab metaphor.

      The metaphor used in a browser with tabs, or a configuration screen with tabs, or an HTML page with tabs is consistent to the degree that each has a set of user interactable elements called tabs and each tab is associated with a set of widgets or content and that when a selected form of interaction (typically a mouse click or keyboard navigation) is performed on a tab the content or widgets of the previously active tab are removed from the screen and the content or widgets of the newly active tab are displayed.

      That a tab is rendered by the OS, by an application, or by HTML/CSS does not negate the common metaphor they share, so if any are tabs they are all tabs.