Gossamer Forum
Home : General : Perl Programming :

desperate: need help creating dynamic array

Quote Reply
desperate: need help creating dynamic array
Hey guys, I need some help from a newbie. Here is what I am trying to
do. People query my flatfile and it returns records with a radio button
list they can click on. http://www.state.sc.us/jmr1/ucheck/search.html
If you look at it, do a search on (wal-mart) that returns about 40
records.

I can get as far as building the dynamic list, but I want the person to
be able to click the radio buttons that apply to them and have it return
all their selections. So far, with this code below, it just returns 2
selections even though you can select x. And it also just returns Total
Selected: 1 no matter how many are selected. Any suggestions on going
about this would be greatly appreciated. Thanks in Advance.

K~

#!/usr/bin/perl
#
# ucheck
#
# Function: Unclaimed Checks Search engine screen #2
# Creates a form for submission
#

$query_string = $ENV{'QUERY_STRING'};



$checkid = 0;
($nme,$id) = split(/=/,$query_string);
@checkid[0] = $id;


if($id > 100){
$checkid = 1;
}


print "Content-type: text/html", "\n\n";

print "<title>South Carolina Unclaimed Checks</title>\n";

print "<body bgcolor=\"#FFFFFF\" text=\"#000000\">\n<center>\n";

print "<h3>South Carolina Unclaimed Checks</h3>\n";


if($checkid < 1) {
print "<h3><font color=red>You must select at least one item from the
previous
page</font></h3>\n";
print "Click on the back button on your browser and select at least one
claim.\n";
print "</center></body>\n";
exit(0);
}


print "<table border=4 bgcolor=white>\n";
print "<tr><th colspan=8><font color=red>Note properties shown are for
\$50.00 and up
only!</font><br>\n";

print "<tr><td>Property ID:<td>";


$pointer=0;
while($pointer < $checkid-1) {
print "@checkid[$pointer]";
$pointer++;
}
$special = @checkid[$checkid-1];

print "$special<tr><td>Total selected:<td>$checkid\n";

print "</table><p><br>\n";
print "<form action =\"/cgi-bin/jmr/test/tchecks2.pl\"
method=\"post\">\n";

print "<table border=0 bgcolor=\"tan\" cellspacing=0>\n";
print "<r><th colspan=2><font size=\"+2\">Contact
Information</font><p><i><font color=blue>Fields in
Blue
are &nbsp;<u>REQUIRED</u>
!!!</font></i><br><hr>\n";
print "<tr><td> <font color=\"0000FF\"><b>Name:</b></font><td><input
type=\"text\" name=\"claimant\"
size=40>\n";
print "<tr><td> <font color=\"0000FF\"><b>Address
1:</b></font><td><input type=\"text\" name=\"street1\"
size=40>\n";
print "<tr><td> Address 2:<td><input type=\"text\" name=\"street2\"
size=40>\n";
print "<tr><td> <font color=\"0000FF\"><b>City</b></font>, <font
color=\"0000FF\"><b>State</b></font>
&nbsp;<font color=\"0000FF\"><b>Zip:</b></font><td><input type=\"text\"
name=\"city\"
size=25> <input type=\"text\" name=\"state\" size=2> <input
type=\"text\" name=\"zip\" size=10>\n";
print "<tr><td> <font color=\"0000FF\"><b>Phone
Number:</b></font><td>(<input type=\"text\"
name=\"areacode\" size=3>) <input type=\"text\" name=\"phonemumber\"
size=8>\n";
print "<tr><td colspan=2> Please include area code above.\n";

print "</table><p><br>\n";

print "</center><br>\n";


print <<EOF;


<b><font size="+2" color="red">NEW !</font> &nbsp; You can print your
own claim form by clicking here.</b> &nbsp;<input type="submit"
name="submt" value="Print Claim Form"> &nbsp; &nbsp; Follow the
directions in Section D of the claim form. &nbsp;Mail the form and all
required information to the State Treasurer's Office.<p><br><br>


If you do not have a printer, click here &nbsp; <input type="submit"
name="submt" value="Email Request for Claim Form"> &nbsp; and a claim
form will be mailed to the address you provided above. &nbsp;Please
allow 2 weeks for the claim form to be mailed.<p><br><br>
<center>

EOF

$pointer=0;
while($pointer < $checkid-1) {
print "<input type=\"hidden\" name=\"claim$pointer\"
value=\"@checkid[$pointer]\">\n ";
$pointer++;
}

print "<input type=\"hidden\" name=\"claim$pointer\"
value=\"@checkid[$checkid-1]\">\n";

if($checkid > 0) {

print "\n<input type =\"reset\" value = \"Clear the Contact
Information\">\n"; }
print "</form>\n";
print "</center></body>\n";

exit(0);
Quote Reply
Re: [kerigan] desperate: need help creating dynamic array In reply to
What I'd do is rename your radio fields so they are all called "id" for example and then change your form method to POST instead of GET.

Then in your script use CGI.pm to handle the form:

use CGI qw/:standard/;

Then you can get all id's like:

my @ids = param('id');

Last edited by:

Paul: Sep 21, 2002, 4:40 AM
Quote Reply
Re: [Paul] desperate: need help creating dynamic array In reply to
Wink Yes, Thank You! Paul. I will definitely start working it that way. I wasn't even thinking about cgi.pm.

k~