On Nov 11, 10:46 am, [EMAIL PROTECTED] (Dermot
Paikkos) wrote:
> Hi
>
>
>
> > -----Original Message-----
> > From: marys [mailto:[EMAIL PROTECTED]
> > Sent: 11 November 2008 11:20
> > To: [EMAIL PROTECTED]
> > Subject: using cgi.pm to create and interpret textboxes
>
> > Hello:
> >  Can anyone tell me how to use CGI.pm's 'textfield' function to set up
> > a form with a lot of fill-in fields and then parse them?  I tried to
> > read three values from input boxes but the output seems to be the name
> > of the textbox and not its value.  Here are two scripts:
>
> > (1) a.cgi:
>
> > #!/usr/bin/perl -wT
> > use CGI::Carp qw(fatalsToBrowser);
> > use CGI ':standard';
> > use strict;
> > use diagnostics;
> > my $z = new CGI;
> > print $z->header;
> > print $z->start_html;
>
> > print $z->h2("Please indicate the length of each leg of the
> > triangle:"),"\n";
>
> > print  $z->startform(-method=>"POST",-action=>"action.cgi");
>
> > my @leglength;
> > my @leg;
>
> > foreach (0..2){
> >    print  $z->h2($leg[$_],"  ",textfield("leglength[$_]"));
> > }
>
> > print $z->submit('Submit');
>
> > print $z->end_html;
>
> _______________________________________________________________________
>
> > ______________________
>
> > (2) action.cgi:
>
> > #!/usr/bin/perl -wT
> > use CGI::Carp qw(fatalsToBrowser);
>
>  Typo here.
>
>  use CGI ':standard';
>
> > use strict;
> > use diagnostics;
> > my $q = new CGI;
> > my @param=param();#these are the contents from textboxes on previous
> > page
> > print $q->header;
> > print $q->start_html;
>
> > my @leglenth;
>
> > my @param=param();
> > my $z;
> > my $a=-1;
>
> The issue is here.
>
> > foreach(0..2){
> > $a+=1;
> > $leglenth[$a] = $param[$a];
> > }
>
> Your puttng the names in the array not the values
>
> you want param($param[$a]);
>
> > my $numelements=scalar(@leglenth);
> > print $q->h2("The number of elements in array [EMAIL PROTECTED] is
> > $numelements\n");
>
> > foreach (@leglenth){
> > print $q->h2("\$leglenth[$_] is $_ \n");
> > }
>
> > print $q->h2("[EMAIL PROTECTED] is @leglenth \n");
>
> > print $q->end_html;
>
> _______________________________________________________________________
>
> > ______________________
> > I illustrated the problem with just three fill-in fields, but I will
> > need many more.  The output of the print statements in the file
> > 'action.cgi' is that each element listed has the name of the element,
> > e.g. "leg[0]" , not the value filled in.  I can pass the values
> > through if I individually label each input box in the input script,
> > but it gets very sloppy and tedious to do it that way.  Does anyone
> > know if it can be done the way I tried?
> > Thank you in advance.
> > Mary
>
> print "===========================\n";
> foreach my $p (@param) {
>         next unless $p =~ /leglength/;
>         print $q->h4("$p = ".$q->param($p));}
>
> print $q->end_html;


Thank you very much.
Mary


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to