CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Passing more than one variable in Perl CGI module: Edit Log



perlFun
User

Mar 10, 2015, 3:42 PM


Views: 5791
Passing more than one variable in Perl CGI module

This will be a very basic question about using Perl's CGI module.

I have a cgi script. At the top of the script, a CGI object is created as follows:

my $query_obj = CGI->new;

When the script is called initially there are no params saved. At the beginning of the script, there is a redirect call as follows:

print $query_obj->redirect($query_obj->url."?<var I want to save>=<value for that var>");

When this code is hit, the URL is called again, only with ?<var I want to save>=<value for that var> tacked on to the URL. Now, <var I want to save> is a parameter that can be accessed via: $query_obj->param("<var I want to save>");


Further down in the script, there is a dropdown menu, as follows:

$query_obj->start_form;
$query_obj->popup_menu(-name=>'a name', -values=>\@values_in_dropdown_menu);
$query_obj->submit('submit','select');
$query_obj->end_form;


When the code $query_obj->submit is hit, the CGI script is called once again, passing down the value the user selected. The problem now is, I've lost access to my <var I want to save>! How can I pass this var as well during the submit call so I can still have access to it when the page is refreshed?


(This post was edited by perlFun on Mar 10, 2015, 3:43 PM)


Edit Log:
Post edited by perlFun (User) on Mar 10, 2015, 3:43 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives