Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Passing variables to frames

Reply
Thread Tools

Passing variables to frames

 
 
divya
Guest
Posts: n/a
 
      02-24-2005
This is the problem I am having:
I have an index page where I obtain input from the user (for example
their date of birth). This information is passed to Page2. Page2 has
frames. Outside of the frames I can access the user's input. But within
the frames I can't seem to be able to get the value. The date is stored
in a global variable.
Here are snippet's of code:

##Variables
my ($BDAY, $path_info, $script_name);

##Obtaining value from the index page
if ($q->param('birthday')) {
$BDAY = $q->param('birthday');
}

##Creating frame
$path_info = $q->path_info;

##Printing the fames
if (!$path_info) {
&print_frameset($BDAY);
exit 0;
}

##Printing the different frames
&print_html_header; ##HTML headers
&print_content if $path_info=~/content/; ##Left pane with links
&print_expand($BDAY) if $path_info=~/expand/; ##Expanded graph
&print_analyse if $path_info=~/analyse/; ##Options to do
analysis
&print_end; ##End HTML
&print_error;

##Setting up the frames
sub print_frameset {

my $birthday = shift;
$script_name = $q->script_name;

print "<html><head><title>$TITLE</title></head>";
print "<frameset cols='8%,92%'>";
print "<frame src='$script_name/content' name='content'>";
print "<frameset rows='70%,30%'>";
if ($birthday) {
print "<frame src='$script_name/expand' name='expand'>";
print "<frame src='$script_name/analyse' name='analyse'>";
}
else {
print "<frame src='$script_name/error' name='error'>";
}
print "</frameset>";
print "</frameset>";

exit 0;
}

One of the frame's contents:
sub print_expand {

my $birthday = shift;
print $q->h3("My birthday is on: $birthday");

}

In this frame all it prints is "My birthday is on: " it is not printing
the variable.

I cannot figure out why I cannot get the value in the subroutines. I
have checked and the value does get passed from the index page to this
page. I can print it from the global variable $BDAY but not from the
sub routines that form the frames.

I have spent almost 2 days on this and I am starting to go insane!! I
would appreciate any hints/help/suggestions you can provide.

Thanks!
Me

 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      02-24-2005
"divya" <> wrote in news:1109216654.641937.174730
@z14g2000cwz.googlegroups.com:

> This is the problem I am having:
> I have an index page where I obtain input from the user (for example
> their date of birth). This information is passed to Page2. Page2 has
> frames. Outside of the frames I can access the user's input. But
> within the frames I can't seem to be able to get the value.


You do not have a Perl question. You just do not know HTML & CGI. You
should direct HTML queries to

comp.infosystems.www.authoring.html

and CGI queries to

comp.infosystems.www.authoring.cgi

> my ($BDAY, $path_info, $script_name);


Declare variables in the smallest applicable scope.

> ##Obtaining value from the index page
> if ($q->param('birthday')) {


$q is not defined at this point.

use strict;
use warnings;

would have told you that.

> $BDAY = $q->param('birthday');
> }
>
> ##Creating frame
> $path_info = $q->path_info;
>
> ##Printing the fames
> if (!$path_info) {
> &print_frameset($BDAY);


Do you know the difference between

&print_frameset($BDAY)

and

print_frameset($BDAY)?

If you do not need the specific effects of using &print_frameset, then
you should not use it. See

perldoc perlsub

for more information.

Sinan
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      02-24-2005
divya wrote:
> This is the problem I am having:
> I have an index page where I obtain input from the user (for example
> their date of birth). This information is passed to Page2. Page2 has
> frames. Outside of the frames I can access the user's input. But within
> the frames I can't seem to be able to get the value.


Do you realize that the script is called multiple times? The first time
it only prints the frameset file.

> print "<frame src='$script_name/content' name='content'>";


Here the script is called a second time from the frameset file, and as
far as I can see, no parameters are passed to it that time...

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      02-24-2005
"A. Sinan Unur" <> wrote in
news:Xns9606EACCF4560asu1cornelledu@127.0.0.1:

> "divya" <> wrote in news:1109216654.641937.174730
> @z14g2000cwz.googlegroups.com:
>
>> This is the problem I am having:
>> I have an index page where I obtain input from the user (for example
>> their date of birth). This information is passed to Page2. Page2 has
>> frames. Outside of the frames I can access the user's input. But
>> within the frames I can't seem to be able to get the value.

>
> You do not have a Perl question. You just do not know HTML & CGI.


Well, I just re-read this, and realized that it comes accross harsher
than I had intended. What you have is:

> print "<frame src='$script_name/expand' name='expand'>";
> print "<frame src='$script_name/analyse'

name='analyse'>";

These will result in two fresh invocations of your script without the
birthday parameter.

See

<URL: http://search.cpan.org/~lds/CGI.pm-3...EATING_A_SELF-
REFERENCING_URL_THAT_PRESERVES_STATE_INFORMATION:>

and

<URL: http://search.cpan.org/~lds/CGI.pm-
3.05/CGI.pm#WORKING_WITH_FRAMES>

for more information.

Sinan.
 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      02-24-2005
A. Sinan Unur wrote:
>
> <URL: http://search.cpan.org/~lds/CGI.pm-3.05/CGI.pm#CREATING_A_SELF-REFERENCING_URL_THAT_PRESERVES_STATE_INFORMATION:>


It should be noted that CGI.pm's self_url() method translates all
parameters, whether submitted via POST or GET, to a query string. If
there initially were info passed to the script, that you wouldn't like
that the server sends to the user and saves in the access log, it may be
advisable to add the necessary query string manually. In this case it
seems to be:

my $querystring = "?birthday=$BDAY";

(The need for URI escaping should better be considered, of course.)

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
Passing variables to frames - cgi divya Perl 1 02-24-2005 10:09 AM
Link needed to go from a non-frames page to a Frames page, and load a particular frame. How? - Newbe Philip HTML 3 06-28-2004 03:06 PM
Help : passing variables through frames on an ASP site ? A Web Master ASP General 4 01-28-2004 04:19 PM
From Frames to no frames? Powerslave2112 HTML 2 01-20-2004 10:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57