Sorry, I chose the wrong words..
my script works similar to the way you described below. Depending on 
which fields are filled out and which button is pressed, a different 
subroutine is called, creating the page.


On Wednesday, May 15, 2002, at 12:01 AM, David Gray wrote:

>> I'm using one CGI script to generate several search pages
>
> That's impossible. One call to a cgi script can generate only one page.
> Consider the following untested  ;) (but simple enough that I probably
> didn't screw it up) code:
>
> --code--
>  #!/usr/bin/perl -w
>  use strict;
>
>  use CGI;
>  my $cgi = new CGI;
>  # this line saves the url of the
>  # currently running CGI script
>  my $me = $cgi->script_name;
>
>  # this is declared as 'our' so
>  # you can use it in your subs
>  # without passing it each time
>  our %F = ();
>
>  # this saves a copy of the form
>  # vars passed to your CGI script
>  # in an easily accessible hash
>  for($cgi->param()) {
>    $F{$_} = $cgi->param($_);
>  }
>
>  # this section calls different subs
>  # (which print different HTML)
>  # based on the value of a parameter
>  # passed to the script.
>  # print_frameset() is the default
>  # which gets called if param(page)
>  # isn't defined or is eq ''
>  if(not defined $F{page} or
>     $F{page} eq '') {
>    print_frameset();
>  } elsif($F{page} eq 'main') {
>    print_main();
>  } elsif($F{page} eq 'nav') {
>    print_nav();
>  } elsif($F{page} eq 'data') {
>    print_data();
>  } else {
>    $F{page} =~ s/[^a-z]//g;
>    print_error();
>  }
>
>  sub print_frameset {
>    print qq^<html>
> <head><title>example frameset</title></head>
> <frameset ...>
>   <frame name="nav" src="$me?page=nav" ...>
>   <frame name="main" src="$me?page=main" ...>
>   <frame name="data" src="$me?page=data" ...>
> </frameset>
> </html>^;
>  }
>
>  sub print_main {
>    print qq^<h1>This is my MAIN PAGE</h1>^;
>  }
>
>  sub print_nav {
>    print qq^<h1>This is my NAV PAGE</h1>^;
>  }
>
>  sub print_data {
>    print qq^<h1>This is my DATA PAGE</h1>^;
>  }
>
>  sub print_error {
>    print qq^<h1>Unsupported page [<font color="red">$F{page}</font>]
> requested</h1>^;
>  }
> --code--
>
> That code generates four html pages (possibly including an error page or
> two), but it gets called four times. Sorry if I'm explaining something
> you already understand, but this is essential.
>
>> (search for
>> people etc) within a secured area.
>> I would like to put the navigation sub into one frame, the retrieved
>> data (sub search1,2...)in another frame.
>> But I do not want to use an  extra script for this.
>
> An adaptation of the above example should work for you.
>
> Good luck,
>
>  -dave
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to