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.
In reply to Re: Creating multiple textfields with for loops and capturing its values with CGI.pm
by Samy_rio
in thread Creating multiple textfields with for loops and capturing its values with CGI.pm
by monkfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |