Here's the whole program,...
#!/usr/bin/perl use strict; use CGI; use Mail::Sendmail; use File::Basename; use MIME::Base64; my $SERVER="http://".$ENV{'SERVER_NAME'}; my $form=$SERVER.$ENV{'SCRIPT_NAME'} || $SERVER.$ENV{'PATH_INFO'}; my $datapath=dirname $0; my $progname=basename$0; my $smtp = "appsmtp.ottawa.ca"; my ($sec,$min,$hr,$day,$mon,$yr)=(localtime); my $today=sprintf("%04d-%02d-%02d %02d:%02d", $yr+1900, $mon+1, $day, +$hr, $min); my $date; my $start_hide; my $end_hide; my $xls_file = "$datapath/working/file.xls"; my %in=(); my %str=(); my %check=(); my $typetext="text"; my $typetextarea="textarea"; my $closetextarea="<\/textarea>"; my $border=0; my $SENDSTR; my $reset; my $ATTACHSTR; my $MAIL_TO='bryson.connolly@ottawa.ca'; my $submitstr; my %mainbody; my $formid; my $debug =0; my $new_form; #------------------ #read form input #------------------ my $query=new CGI; my $action=$query->param('action'); my $lang=$query->param('lang'); $formid=&newformid; if ($lang ne "_fr") { $lang="_en"; $SENDSTR="Submit"; $reset="Reset"; $ATTACHSTR=''; } else { $SENDSTR="Soumettre"; $reset="reset"; $ATTACHSTR=''; } my $tpl = "registration$lang.html"; $submitstr="<input type=submit name=action value=\"$SENDSTR\"> &nbsp;" +; $reset="<INPUT type=reset value=Reset name=resetbutton> &nbsp;"; print "Content-type: text/html\n\n"; &getdata; if ($action eq $SENDSTR) { $typetext="hidden"; $typetextarea="input type=hidden"; $closetextarea=""; %str=%in; $submitstr=""; $reset=""; $ATTACHSTR=""; $date=$today; mailto($query); } my $tmp= &readhtml("$datapath/$tpl"); #$tmp=&doclean($tmp); print $tmp; exit; #return htmlfile from template sub readhtml { my $selectname; my $retfile; open (DATA, "@_") || print "@_ file not found"; while (<DATA>) { #parse input data #input type must be specified #type specified right after <input #name must only contain "A-Za-z0-9_" s|<input type=text([^>]?name=)"?(\w+)"?(.*?>)|<input type=$typ +etext $1$2 value="$in{$2}" $3 <b><tt>$str{$2}</tt></b>|ig; #s|<textarea([^>]?)name=(\w+)(.*?>)|<$typetextarea $1 name=$2 +value="$in{$2}"$3$in{$2}|ig; s|<textarea(.*)name="?(\w+)"?(.*?>)|<$typetextarea $1 name=$2 +value="$in{$2}" $3 $in{$2}|ig; s|</textarea>|$closetextarea|ig; s|(<input type=radio)(.*)( name=)(\w+)( value="?)([\w\.\s\~]+) +("?)|$1$2$3$4$5$6$7 $check{$4.$6}|ig; s|(<input type=checkbox)(.*)( name=)(\w+)|$1$2$3$4 $check{$4}| +ig; s/(\$[\w{}]+)/$1/eeg; #now to do the selects if ( /<select name="?(\w+)"?/ig ) {$selectname=$1} s/(<option value="?)([\w\@\,\;\.\s\&\/]+)("?)(.*?>)/$1$2$3 $ch +eck{$selectname.$2}$4/ig; s|<option>(.*)</option>| package temp; my $tmp; if ( ($check{$selectname.$1}) or ($typetext eq "text") ) { $tmp="<option $check{$selectname.$1}>$1</option>"; + } $tmp |sgeix; $retfile.=$_; } close (DATA); return $retfile; } sub getdata { # $_ is the form element name and $in{$_} is the cont +ents. if ($action eq $SENDSTR) { open(OUT,">>$xls_file") || print "could not open $xls_file" + ; } foreach ($query->param) { $in{$_} = $query->param($_); if ($_=~/^c_/) { $check{$_}="CHECKED" } #chec +kbox if ($_=~/^r_/) { $check{$_.$in{$_}}="CHECKED" } #radi +o if ($_=~/^s_/) { $check{$_.$in{$_}}="SELECTED" } #Sel +ect if ($action eq $SENDSTR) { $in{$_}=~s/\r\n/ /g; if ($_ !~/action|lang/) { # don't print these fields to X +LS file print OUT "$in{$_}\t"; } } $in{$_}=~s/\r\n/<br>/g || $in{$_}=~s/<br>/\n/g; $in{$_}=~s/"/&quot;/g; $in{$_}=~s/'/&rsquo;/g; $in{$_}=~s/\$/&\#36;/g; } # end foreach if ($action eq $SENDSTR) { print OUT "$today\t"; print OUT "\n"; close(OUT); } } sub mailto { blah blah,,,send mail } sub newformid { use File::CounterFile; $File::CounterFile::DEFAULT_DIR="$datapath/working"; my $c = File::CounterFile->new("counter.dat"); return $c->inc; } sub doclean { #remove the hidden fields and submit/reset buttons ($_)=@_; undef $/; s|<input (type=hidden.*?)>|<skip $1>|imsg; s|<input type="+submit.*?>||imsg; s|<input type="+reset.*?>||imsg; $/="\n"; return $_; }

So, I want to print "do data" when the checkbox isn't checked. An easier way would be to just name all the checkboxes different. Ex: check1_checked. It won't line up in the spreadsheet, but the data will be there. although, I wouldn't mind figuring out how to print "do data" when it's not checked. I understand that it's not in the param list when it's blank... just trying to figureout the best way to trap that without messing with the program too much.

In reply to Re^2: checkbox help by djbryson
in thread checkbox help by djbryson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.