PDA

View Full Version : Check All Checkboxes in cgi-script


snowball
01-28-2004, 09:30 PM
Hi

Can anyone help please ...... I have a simple cgi-script which has a form in it, with checkboxes.

Is there any way I can include a check all, and uncheck all at the bottom of the list of checkboxes.

Obviously if this were an html page I could use Java, but how can I do it, if the page created comes from a cgi-script?



print <<EOF;
<form action=$ENV{'SCRIPT_NAME'} method=POST
onSubmit="return delWarning()">
<input type=HIDDEN name="action" value="killmail">
<center><table border="1" cellpadding="0" width="100%" $toptablebg>
<tr><td>&nbsp;</td><td><b><font color=$headfontcolor>Subject</font></b></td><td><b><font color=$headfontcolor>From</font></b></td>
<td><b><font color=$headfontcolor>Date</font></b></td><td align=center><b><font color=$headfontcolor>Size</font></b></td></tr>
EOF
$row = 0;
foreach $msgid (sort { $a <=> $b }keys %$messages) {
next unless (&readpop($msgid));
$MSG = "M$msgid";
$dchk=0;
$numchk=1;

$fromchg = $from;
$fromchg =~ s/\(/<b>/g;
$fromchg =~ s/\)/<\/b><br><small>/g;
@datetimechg = split (/ /, $datetime);

$trash = chop($head{'message-id'});
open(DEAL, "<./letters/dealers.txt");
@dealers = <DEAL>;
close(DEAL);

foreach $_ (@dealers) {
@deal = split (/\|/, $_);
if ($deal[0] eq $head{'message-id'}) {
print "<tr><td align=center bgcolor=$deal[1]><input type=CHECKBOX name=$MSG></td><td>$mainfont<a href=$ENV{'SCRIPT_NAME'}\?action=showmail\&MID=$msgid><font color=red>$subject</font></a></td><td>$mainfont$fromchg</small></td><td>$mainfont<small>$datetimechg[0] $datetimechg[1] $datetimechg[2] $datetimechg[3]<br>$datetimechg[4] $datetimechg[5]</small></td><td align=center>$mainfont$size</td></tr>";
$dchk=1;
last;
}
}
if ($dchk == 0) {
print "<tr><td align=center><input type=CHECKBOX name=$MSG></td><td>$mainfont<a href=$ENV{'SCRIPT_NAME'}\?action=showmail\&MID=$msgid><font color=red>$subject</font></a></td><td>$mainfont$fromchg</small></td><td>$mainfont<small>$datetimechg[0] $datetimechg[1] $datetimechg[2] $datetimechg[3]<br>$datetimechg[4] $datetimechg[5]</small></td><td align=center>$mainfont$size</td></tr>";
}
}


if ($numchk == 0) {
print "<tr><td colspan=5 align=left><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font face=\"arial,verdana\" size=\"2\" color=3366cc><b>No Messages: &nbsp;$wday $mday $mon $year &nbsp;$hour:$min:$sec</b><br><br><br></font></td></tr>";
}


&closepop;

print <<"EOF";
</table><p>
<table border=0><tr valign=top>
<td><input type=submit value="Delete Messages" name=delete></form>
</td><td width=50>&nbsp;</td><td>
EOF




Any suggestions would be greatfully received.

Thanks

Snow ..

Jeff Mott
01-28-2004, 09:58 PM
You just otuput JavaScript code the same way you would output HTML from the script.

e.g.,
print <<EOF;
<script type="text/javascript">
alert("Hello, world!");
</script>
EOF