Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Creating multiple textfields with for loops and capturing its values with CGI.pm

by Samy_rio (Vicar)
on Jun 15, 2006 at 04:08 UTC ( #555421=note: print w/replies, xml ) Need Help??


in reply to Creating multiple textfields with for loops and capturing its values with CGI.pm

Hi monkfan, Get the User input and do as below:

#!C:\perl\bin\perl use strict; use diagnostics; use Data::Dumper; use CGI qw/:standard :html3/; use CGI::Carp qw( fatalsToBrowser ); my $nbr_of_fields = 15; # This is taken as user input print header("text/html"); print start_html(); print start_form({-method=>"post", -action=>"test.cgi"}),br; for (0..$nbr_of_fields - 1) { print textfield(-name=>"field_name$_", -value=>5, -size=>50, -maxlength=>80); } print hidden({-name=>"User_Input", -value=>"$nbr_of_fields"}); print submit({-name=>'action', -value => 'Submit' }), end_form, end_html;

Fetch the Fields value as follow:

Test.cgi -------- #!C:\perl\bin\perl use strict; use diagnostics; use Data::Dumper; use CGI qw/:standard :html3/; use CGI::Carp qw( fatalsToBrowser ); my $user_input = param('User_Input'); print header("text/html"); print start_html(); for (0..$user_input - 1) { print "Filed_name$_ :   ", param("field_name$_") +,br; } print end_html;

I think this will help you.

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://555421]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-07-23 17:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (472 votes). Check out past polls.

    Notices?