Do you know where your variables are? PerlMonks

### Re^2: How to extract a form data in cgi perl

by Sinistral (Prior)
 on May 02, 2012 at 20:49 UTC ( #968539=note: print w/replies, xml ) Need Help??

in reply to Re: How to extract a form data in cgi perl
in thread How to extract a form data in cgi perl

You don't have to have values for options. On form submit the value for the element is the string value between the opening and closing option tags. So that's not it.

If you take the action out and leave everything else intact, you can see the GET values in the URL bar in your browser:

<form name="frmStatusFilter" method="GET">

Choose Filter:<select name="StatusFilterSelect" onChange="frmStatusFil
+ter.submit()">

<option>Show with status</option>
<option>Show all</option>

</select>

</form>
[download]
When I do that, I see the value set. That means your CGI code had something wrong. I created a file called mycgi.pl and put it in the same directory as the HTML file, resulting in this for the form definition:
<form name="frmStatusFilter" method="GET" action="mycgi.pl">
[download]

You would, of course, leave yours as the same, since you have a specific CGI URL already defined.

Then I worked on the contents of mycgi.pl and added some missing CGI method calls:

my $q = new CGI; my$status = $q->param('StatusFilterSelect'); print$q->header(),
$q->start_html('Status Report'),$q->h1('Status Report'),
$q->p("status is$status"),
\$q->end_html();
[download]

You left off the header, which is very important to tell the browser that what's coming back is an HTML page. You also want the start_html to emit the html, head, and body tags. The h1 is purely optional, the p is for your data, and the end_html closes off the body and html tags to make everything neat, tidy, and validateable.

Log In?
 Username: Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://968539]
help
Chatterbox?
 [thezip]: Is there an analogy for '&' (ie. run commandline process in background) for Windows commandline? [Corion]: thezip: start "some title" path\to\that\ application, but that will open another console window [Corion]: thezip: If you want to confuse your users, use system(1, "that\\command" );, which will make Perl launch it in the background [Corion]: That will keep the console window open even though the user can't type into it anymore [thezip]: So I have a script that generates a log file. After script completion, I want tohave VIM open this logfile.

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (14)
As of 2017-03-27 18:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Should Pluto Get Its Planethood Back?

Results (321 votes). Check out past polls.