http://picocheep/cgi-bin/killbill/forms1.pl?TextfieldOne=I+entered+my+text+here
# Indicate we are creating a form.
# For this example, everything defaults. We will flesh it out later.
# print $query->startform({-method=>'post'});
print $query->startform({-method=>'get'});
print $query->endform();
# Generate a text box for data entry
# Render it regardless of if we have previously entered text or not.
print $query->h1('Please enter some text');
print $query->textfield({-name=>'TextfieldOne',
-default=>'Enter your text here',
-size=>50,
-maxlength=>100});
# Now conditionally report what the user typed in previously.
# If this is not the first time into the script...
if ($query->param()) {
# Extract out whatever the contents of our field were.
my $textInput = $query->param(-name=>'TextfieldOne');
# Generate our output
print $query->hr();
print $query->p('The text you previously entered was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
}
#!C:\perl\bin\perl.exe -w
use CGI;
use strict;
# Create a perlCGI object. It automatically picks up any arguments on
# the incoming URL.
my $query = new CGI;
# Create a header, and let it default arguments, it likely knows
# better then we do.
print $query->header();
# Start the body of our document, and give it a title (shows up on the
# browser bar and on printouts). All the legal fields within the HTML
# "BODY" tag are supported, and are optional. Other unsupported
# options can be specified as well, and will be correctly added. Note
# that there is nothing actually in the body tag, just HTML modifiers
# being specified.
print $query->start_html({-title=>'Form Test One...',
-author=>'Bill Kilgallon'});
print $query->hr();
# Indicate we are creating a form.
# For this example, everything defaults. We will flesh it out later.
# print $query->startform({-method=>'post'});
print $query->startform({-method=>'get'});
# Generate a text box for data entry
# Render it regardless of if we have previously entered text or not.
print $query->h1('Please enter some text');
print $query->textfield({-name=>'TextfieldOne',
-default=>'Enter your text here',
-size=>50,
-maxlength=>100});
print $query->endform();
# Now conditionally report what the user typed in previously.
# If this is not the first time into the script...
if ($query->param()) {
# Extract out whatever the contents of our field were.
my $textInput = $query->param(-name=>'TextfieldOne');
# Generate our output
print $query->hr();
print $query->p('The text you previously entered was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
}
# And finally, end the document.
print $query->end_html;
# Generate a submit button for this form print $query->submit();
# Generate a reset button for this form print $query->reset();
# Generate a text field for data entry
print $query->h1('Please enter some text');
print $query->textfield({-name=>'TextfieldOne',
-default=>'Enter your text here',
-size=>50,
-maxlength=>100});
# Extract out whatever the contents of our text field were.
my $textInput = $query->param(-name=>'TextfieldOne');
# Generate our output
print $query->p('The text you previously entered was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
# Generate a text area for data entry
print $query->h1('Please enter some more text');
print $query->textarea({-name=>'TextareaOne',
-default=>'Enter lots of your text here',
-rows=>4,
-columns=>60});
# Extract out whatever the contents of our text area was.
my $textInput = $query->param(-name=>'TextareaOne');
print $query->p('The text area contents were:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
# Generate a password area
# Render it regardless of if we have previously entered text or not.
print $query->h1('Please enter some secret text');
print $query->password_field({-name=>'PasswordareaOne',
-default=>'Your Password',
-size=>10,
-maxlength=>60});
# Extract out whatever the contents of our password area were.
my $textInput = $query->param(-name=>'PasswordareaOne');
print $query->hr();
print $query->p('The Password entered was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Generate a popup menu
print $query->h1('Choose from the following menu');
print $query->popup_menu({-name=>'PopupOne',
-values=>['First Choice', 'Second Choice',
'Third Choice', 'Fourth Choice',
'Fifth Choice'],
-defaults=>'Fifth Choice'});
# Extract out whatever the contents of our popup area were.
my $textInput = $query->param(-name=>'PopupOne');
print $query->hr();
print $query->p('The popup selected was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Generate a scrolling list
print $query->h1('Choose from the following list');
print $query->scrolling_list({-name=>'ScrolllistOne',
-values=>['First Choice', 'Second Choice',
'Third Choice', 'Fourth Choice',
'Fifth Choice'],
-multiple=>'true',
-defaults=>'Fifth Choice'});
# Extract out whatever the scrolling list was
my @textInput = $query->param(-name=>'ScrolllistOne');
print $query->hr();
print $query->p('The scrolling list selects were:'), $query->br();
print $query->em({-align=>'center'}, @textInput);
print $query->hr();
# Generate a checkbox for selecting zero or more elements from a list
print $query->checkbox_group({-name=>'CheckboxOne',
-values=>['First Box','Second Box', 'Third Box',
'Fourth Box', 'Fifth Box'],
-defaults=>['Second Box','Fifth Box']});
# Extract out whatever the contents of our checkbox were.
my @textInput = $query->param(-name=>'CheckboxOne');
print $query->hr();
print $query->p('The checkbox entries you selected were:'), $query->br();
print $query->em({-align=>'center'}, @textInput);
print $query->hr();
# Generate a standalone checkbox, initialize checked
print $query->checkbox({-name=>'CheckboxAloneOne',
-checked=>'checked'});
print $query->br();
# Extract out whatever the state of the standalone checkbox was.
# (Either "on" or an empty string)
my $textInput = $query->param(-name=>'CheckboxAloneOne');
print $query->hr();
print $query->p('The checkboxalone state was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Generate a Radio Group
print $query->h1('Choose only one from the following list');
print $query->radio_group({-name=>'RadioOne',
-values=>['First Choice', 'Second Choice',
'Third Choice', 'Fourth Choice',
'Fifth Choice'],
-default=>'Second Choice'});
# Extract out whatever the radio group was
my $textInput = $query->param(-name=>'RadioOne');
print $query->hr();
print $query->p('The radio group select was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Generate my URL
print $query->br("My full URL:", $query->url() );
print $query->br("My relative URL:", $query->url(-relative=>1) );
print $query->br("My absolute URL:", $query->url(-absolute=>1) );
print $query->br("My URL with path:", $query->url(-path_info=>1) );
print $query->br("My URL with path and query info:",
$query->url(-path_info=>1, -query=>1) );
print $query->hr();
#!C:\perl\bin\perl.exe -w
use CGI;
use strict;
my $query=new CGI;
# Create a header, and let it default arguments, it likely knows
# better then we do.
print $query->header();
# Start the body of our document, and give it a title
print $query->start_html({-title=>'Compuware Perl Class State Example...',
-author=>'Bill Kilgallon'});
my $currentState = $query->param('myState');
# First time in the form, no state value exists
if ( ! $currentState ) {
# Start the input form
print $query->startform({-method=>'post'});
# Print Name form field
print $query->h2("Please enter your Name: ");
print $query->textfield({-name=>'userName'});
# Print Employee Number form field
print $query->h2("Please enter your Employee ID Number:");
print $query->textfield({-name=>'employeeId'});
print $query->p();
# Create a hidden field that maintains state so we know where we
# are in the sequence of forms.
$query->param('myState', 'DoPageTwo');
print $query->hidden({-name=>'myState'});
# Submit button
print $query->submit();
# End the form
print $query->endform();
}
# See if we are in stage two of our form list
elsif ( $currentState eq 'DoPageTwo' )
{
# Start the input form
print $query->startform({-method=>'post'});
# Print Date form field
print $query->h2("Please enter Todays Date: ", $query->br());
print $query->textfield({-name=>'theDate'});
# Create a hidden field that maintains state so we know where we
# are in the sequence of forms.
$query->param('myState', 'DoPageThree');
print $query->hidden({-name=>'myState'});
# We also need to carry along some other hidden fields, to
# propagate the info from the first form through this second
# form, and on to the third form, etc.
print $query->hidden({-name=>'userName'});
print $query->hidden({-name=>'employeeId'});
print $query->hidden({-name=>'theDate'});
# Submit button
print $query->submit();
# End the form
print $query->endform();
}
# See if we are in stage three of our form list
elsif ( $currentState eq 'DoPageThree' )
{
# Continue to carry along necessary hidden fields
print $query->hidden({-name=>'userName'});
print $query->hidden({-name=>'employeeId'});
print $query->hidden({-name=>'theDate'});
print $query->h1("Here are the values you input so far:");
print $query->p($query->em("userName: ") . $query->param('userName'));
print $query->p($query->em("employeeId: ") . $query->param('employeeId'));
print $query->p($query->em("theDate: ") . $query->param('theDate'));
print $query->hr();
# Set the state for the link to be generated for option one
$query->param('myState', 'DoPageFourA');
print $query->a({-href=>$query->url({-query=>1})},
"Choose Link A" );
print $query->br();
# Set the state for the link to be generated for option two
$query->param('myState', 'DoPageFourB');
print $query->a({-href=>$query->url({-query=>1})},
"Choose Link B" );
print $query->hr();
}
# See if we are in form 4, branch A of our state thread
elsif ( $currentState eq 'DoPageFourA' )
{
print $query->h1("You chose ", $query->em("Option A"));
print $query->hr();
print $query->h2("Here are the values you input so far:");
print $query->p($query->em("userName: ") . $query->param('userName'));
print $query->p($query->em("employeeId: ") . $query->param('employeeId'));
print $query->p($query->em("theDate: ") . $query->param('theDate'));
print $query->hr();
}
# See if we are in form 4, branch B of our state thread
elsif ( $currentState eq 'DoPageFourB' )
{
print $query->h1("You chose ", $query->em("Option B"));
print $query->hr();
print $query->h2("Here are the values you input so far:");
print $query->p($query->em("userName: ") . $query->param('userName'));
print $query->p($query->em("employeeId: ") . $query->param('employeeId'));
print $query->p($query->em("theDate: ") . $query->param('theDate'));
print $query->hr();
}
# And finally, end the document.
print $query->end_html;
#!C:\perl\bin\perl.exe -w
use CGI;
use strict;
# Create a perlCGI object. It automatically picks up any arguments on
# the incoming URL.
my $query = new CGI;
# Create a header, and let it default arguments, it likely knows
# better then we do.
print $query->header();
# Start the body of our document, and give it a title (shows up on the
# browser bar and on printouts). All the legal fields within the HTML
# "BODY" tag are supported, and are optional. Other unsupported
# options can be specified as well, and will be correctly added. Note
# that there is nothing actually in the body tag, just HTML modifiers
# being specified.
print $query->start_html({-title=>'Form Test One...',
-author=>'Bill Kilgallon'});
print $query->hr();
# Indicate we are creating a form.
# For this example, everything defaults. We will flesh it out later.
print $query->startform({-method=>'post'});
# print $query->startform({-method=>'get'});
# Generate a text field for data entry
print $query->h1('Please enter some text');
print $query->textfield({-name=>'TextfieldOne',
-default=>'Enter your text here',
-size=>50,
-maxlength=>100});
print $query->br();
# Generate a text area for data entry
print $query->h1('Please enter some more text');
print $query->textarea({-name=>'TextareaOne',
-default=>'Enter lots of your text here',
-rows=>4,
-columns=>60});
print $query->br();
# Generate a password area
print $query->h1('Please enter some secret text');
print $query->password_field({-name=>'PasswordareaOne',
-default=>'Your Password',
-size=>10,
-maxlength=>60});
print $query->br();
# Generate a popup menu
print $query->h1('Choose from the following menu');
print $query->popup_menu({-name=>'PopupOne',
-values=>['First Choice', 'Second Choice',
'Third Choice', 'Fourth Choice',
'Fifth Choice'],
-defaults=>'Fifth Choice'});
print $query->br();
# Generate a scrolling list
print $query->h1('Choose from the following list');
print $query->scrolling_list({-name=>'ScrolllistOne',
-values=>['First Choice', 'Second Choice',
'Third Choice', 'Fourth Choice',
'Fifth Choice'],
-multiple=>'true',
-defaults=>'Fifth Choice'});
print $query->br();
# Generate a checkbox for selecting zero or more elements from a list
print $query->checkbox_group({-name=>'CheckboxOne',
-values=>['First Box','Second Box', 'Third Box',
'Fourth Box', 'Fifth Box'],
-defaults=>['Second Box','Fifth Box']});
print $query->br();
# Generate a standalone checkbox, initialize checked
print $query->checkbox({-name=>'CheckboxAloneOne',
-checked=>'checked'});
print $query->br();
# Generate a Radio Group
print $query->h1('Choose only one from the following list');
print $query->radio_group({-name=>'RadioOne',
-values=>['First Choice', 'Second Choice',
'Third Choice', 'Fourth Choice',
'Fifth Choice'],
-default=>'Second Choice'});
print $query->br();
# Generate a submit button for this form
print $query->submit();
# Generate a reset button for this form
print $query->reset();
print $query->endform();
print $query->hr();
# Now conditionally report what the user typed in previously.
# If this is not the first time into the script...
if ($query->param()) {
# Extract out whatever the contents of our text field were.
my $textInput = $query->param(-name=>'TextfieldOne');
print $query->hr();
print $query->p('The textfield entered was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Extract out whatever the contents of our text area were.
my $textInput = $query->param(-name=>'TextareaOne');
print $query->hr();
print $query->p('The textarea entered was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Extract out whatever the contents of our password area were.
my $textInput = $query->param(-name=>'PasswordareaOne');
print $query->hr();
print $query->p('The Password entered was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Extract out whatever the contents of our popup area were.
my $textInput = $query->param(-name=>'PopupOne');
print $query->hr();
print $query->p('The popup selected was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Extract out whatever the scrolling list was
my @textInput = $query->param(-name=>'ScrolllistOne');
print $query->hr();
print $query->p('The scrolling list selects were:'), $query->br();
print $query->em({-align=>'center'}, @textInput);
print $query->hr();
# Extract out whatever the contents of our checkbox were.
my @textInput = $query->param(-name=>'CheckboxOne');
print $query->hr();
print $query->p('The checkbox entries you selected were:'), $query->br();
print $query->em({-align=>'center'}, @textInput);
print $query->hr();
# Extract out whatever the state of the standalone checkbox was.
# (Either "on" or an empty string)
my $textInput = $query->param(-name=>'CheckboxAloneOne');
print $query->hr();
print $query->p('The checkboxalone state was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Extract out whatever the radio group was
my $textInput = $query->param(-name=>'RadioOne');
print $query->hr();
print $query->p('The radio group select was:'), $query->br();
print $query->em({-align=>'center'}, $textInput);
print $query->hr();
# Generate my URL
print $query->br("My full URL:", $query->url() );
print $query->br("My relative URL:", $query->url(-relative=>1) );
print $query->br("My absolute URL:", $query->url(-absolute=>1) );
print $query->br("My URL with path:", $query->url(-path_info=>1) );
print $query->br("My URL with path and query info:",
$query->url(-path_info=>1, -query=>1) );
print $query->hr();
}
# And finally, end the document.
print $query->end_html;
#!C:\perl\bin\perl.exe -w
use CGI;
use strict;
# Demonstration program of using arrays to build up and nest HTML
# constructs using arrays and scalars.
#
# Bill Kilgallon, 5/15/00
# Bill@KilgallonFamily.Com
# This software released via the Artistic License
#
# Create our CGI object so we can get at the methods we want.
my $query=new CGI;
# Create a header, and let it default arguments, it likely knows
# better then we do.
print $query->header();
# Start the body of our document, and give it a title
print $query->start_html({-title=>'Table Demo',
-author=>'Bill Kilgallon'});
# Declare some variables
my (@rowOneData, @rowTwoData, @rowThreeData, @rowFourData);
my ($rowOneHtml, $rowTwoHtml, $rowThreeHtml, $rowFourHtml);
my $number;
# We will start from the inside out, and build up from the simplest
# parts. These will then be gradually assembled to make the entire
# table construct.
# First, the easy part, the header row.
# Use our normal HTML generation logic, but instead of printing
# it out, save it in a scaler string variable.
my $headerHtml = $query->th(['Column One', 'Column Two', 'Column Three',
'Column Four']);
# Now, create the text entry fields for the rows. This time, we will
# use the push function to build up an array of individual form field
# strings. This will be helpfull later, as the perlCGI table
# functions are distributive. That is, they will automatically apply
# themselves to each element within an array. Again, instead of
# printing it out now, create an array for future use. We are
# building up pieces.
# Note also that we are letting the loop variable change the field
# name... in effect we are dynamically naming our variables
# (FieldOneOne, FieldOneTwo, FieldOneThree, etc).
foreach $number ("One","Two","Three","Four") {
push (@rowOneData, $query->textfield({-name=>"FieldOne$number"}));
push (@rowTwoData, $query->textfield({-name=>"FieldTwo$number"}));
push (@rowThreeData, $query->textfield({-name=>"FieldThree$number"}));
push (@rowFourData, $query->textfield({-name=>"FieldFour$number"}));
}
# Now, convert the text fields built above into table data entries.
# Because the CGI methods are distributive, we only need to call the
# method once and pass it the whole array, and the HTML and
# constructs will be automatically created for each element within the
# array, and the whole mess will be returned as a big long html
# string. We will save this string to be output later.
# Note we could have generated yet another array here also using push,
# and then in the section below where the Tr() constructs appear use
# the distributive proerty of that method as well, and had a lot less
# typing. Instead, I figured you are confused enough at this point,
# and opted for clarity over elegance.
$rowOneHtml = $query->td(\@rowOneData);
$rowTwoHtml = $query->td(\@rowTwoData);
$rowThreeHtml = $query->td(\@rowThreeData);
$rowFourHtml = $query->td(\@rowFourData);
# Last part to be built (and another easy one)... Build my caption
my $tableCaption = $query->caption("Bills Sample Table");
# Now, build up an entire table based on the parts assembled above
# into one big long HTML string.
my $myTable = $query->table({-border=>'5'},
$tableCaption,
$query->Tr($headerHtml),
$query->Tr($rowOneHtml),
$query->Tr($rowTwoHtml),
$query->Tr($rowThreeHtml),
$query->Tr($rowFourHtml));
# Start the form
print $query->startform({-method=>'post'});
# Dump all the previously built up HTML code to the screen.
print $myTable;
# Create and display the submit and reset buttons
print $query->submit();
print $query->reset();
# display the HTML form end construct.
print $query->endform();
# And finally, end the document.
print $query->end_html;