awohld has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -wT use CGI::Carp qw(fatalsToBrowser); use strict; use CGI; my $cgi = CGI->new(); # Create new CGI object. my $AuthorID; #Make $AuthorID global my $AuthorName; #Make $AuthorName global my $LocationLongitude; #Location longitude global my $LocationLatitude; #Location latitude global my $WarningLongitude; my $WarningLatitude; my @warningPoints; if ($cgi->param("LocationLongitude") && $cgi->param("LocationLatitude" +)) { # If Lat/Long present, add your warning points $LocationLongitude = $cgi->param("LocationLongitude"); $LocationLatitude = $cgi->param("LocationLatitude"); $AuthorID = $cgi->param("AuthorID"); $AuthorName = $cgi->param("AuthorName"); &print_warning_page; exit; } if ($cgi->param("AuthorID")) { #If author is passed back to the scrip +t, save the author info and goto the location page $AuthorID = $cgi->param("AuthorID"); &print_location_page; exit; } else {&print_author_page;} sub print_author_page { &print_header; print $cgi->start_form; print $cgi->popup_menu(-name=>'AuthorID', -values=>[qw/bob cecil/], -labels=>{'1'=>'bob', '2'=>'cecil'}, -default=>'bob'); print "<br>"; print $cgi->submit('Go'); print $cgi->end_form; } sub print_location_page { &print_header; print $cgi->start_form; print $cgi->hidden('AuthorID',"$AuthorID"); $LocationLatitude = $cgi->textfield(-name=>'LocationLatitude',-siz +e=>10,-maxlength=>10); $LocationLongitude = $cgi->textfield(-name=>'LocationLongitude',-s +ize=>10,-maxlength=>10); print <<EOF; <table border="0"> <tr> <td height="37">AuthorID: </td> <td height="37">$AuthorID</td> <td height="37"></td> </tr> <tr> <td>Location Longitude: </td> <td>$LocationLongitude</td> <td>( X Coord )</td> </tr> <tr> <td>Location Latitude: </td> <td>$LocationLatitude</td> <td>( Y Coord )</td> </tr> </table> EOF print "<br>"; print $cgi->submit('Go'); print $cgi->end_form; } sub print_warning_page { &print_header; print $cgi->start_form; print $cgi->hidden('AuthorID',"$AuthorID"); print $cgi->hidden("LocationLongitude","$LocationLatitude"); print $cgi->hidden("LocationLatitude","$LocationLatitude"); $WarningLatitude = $cgi->textfield(-name=>'Latitude',-size=>10,-ma +xlength=>10); $WarningLongitude = $cgi->textfield(-name=>'Longitude',-size=>10,- +maxlength=>10); print <<EOF; <table border="0"> <tr> <td height="37">AuthorID: </td> <td height="37">$AuthorID</td> <td height="37"></td> </tr> <tr> <td>Location Longitude: </td> <td>$LocationLongitude</td> <td>( X Coord )</td> </tr> <tr> <td>Location Latitude: </td> <td>$LocationLatitude</td> <td>( Y Coord )</td> </tr> EOF my $point = 1; foreach (@warningPoints) { my $WPLong = shift @warningPoints; my $WPLat = shift @warningPoints; print <<EOF; <tr> <td>Warning Longitude $point: </td> <td>$WPLong</td> <td>( X Coord )</td> </tr> <tr> <td>Warning Latitude $point: </td> <td>$WPLat</td> <td>( Y Coord )</td> </tr> EOF print $cgi->hidden("WPLong$point","$WPLong"); print $cgi->hidden("WPLat$point","$WPLat"); $point++; } print <<EOF; <tr> <td>Warning Longitude: </td> <td>$WarningLongitude</td> <td>( X Coord )</td> </tr> <tr> <td>Warning Latitude: </td> <td>$WarningLatitude</td> <td>( Y Coord )</td> </tr> </table> EOF print $cgi->checkbox(-name=>'checkbox_name', -checked=>1, -value=>'ON', -label=>'This is the last warning point.'); print "<br>"; print $cgi->submit('Go'); print $cgi->end_form; } sub print_header { print $cgi->header; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need Help With Writers Block
by Fang (Pilgrim) on Sep 05, 2005 at 06:45 UTC | |
|
Re: Need Help With Writers Block
by graff (Chancellor) on Sep 05, 2005 at 07:21 UTC | |
|
Re: Need Help With Writers Block
by monarch (Priest) on Sep 05, 2005 at 06:47 UTC | |
|
Re: Need Help With Writers Block
by jhourcle (Prior) on Sep 05, 2005 at 13:08 UTC | |
|
Re: Need Help With Writers Block
by raptnor2 (Beadle) on Sep 05, 2005 at 17:57 UTC |