neversaint
neversaint

Reputation: 64024

How to name a link using CGI.pm

I intend to create the following HTML using CGI.pm It simply contain 2 frames.

--------------------------------
   Frame1          |
   link1           |  Frame2
   link2           |
   etc             |
---------------------------------

The user will click a link in Frame 1 and the result will appear in Frame 2.

To do that I want to name "link1" etc in the cgi-script in Frame1 (as query), and then appear in Frame2 (as response). I'm not sure how to achieve that in CGI.

This is the current script I have:

#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;


my $TITLE = "My title";
my $query = new CGI;
my $path_info = $query->path_info;


print $query->header();

$path_info = $query->path_info();


# If no path information is provided, then we create 
# a side-by-side frame set
if (!$path_info) {
      &print_frameset;
      exit 0;
}


&print_html_header;
&print_query if $path_info=~/query/;
&print_response if $path_info=~/response/;


&print_end;

sub print_html_header {  
print 
    $query->start_html(-title =>'My title',
       -bgcolor=> "F5F5EB",      
       -style => {
            -src => '../print.css',   
            -align=>'center',         
       }
    ),p;
}


sub print_end {
       print $query->end_html;
 }

# Create the frameset
sub print_frameset {
    my $script_name = $query->script_name;
    print <<EOF;
<html><head><title>$TITLE</title></head>
<frameset cols="35,65" frameborder=0 marginwidth=0 noresize>
<frame src="$script_name/query" name="query">
<frame src="$script_name/response" name="response">
</frameset>
EOF
   ;
    exit 0;
}


sub print_query {
    $script_name = $query->script_name;

    print "<H1>Frame1</H2>\n";

   # This is where I want to name "Link1" so that
   # it can be called later in response frame

   # But this doesn't seem to work
   print h3("Link1", -name =>'link1");

}

sub print_response {
   print "<H1>Frame2</H2>\n";
   # If name == link1 do something...
}

Upvotes: 0

Views: 523

Answers (1)

Toto
Toto

Reputation: 91430

In your sub print_query, just do:

print a({-href=>"$script_name/whatever_you_want", -target=>'response'}, "Link1"),

Upvotes: 1

Related Questions