I have a hopefully quick question. I am trying to add a select all checkbox to the piece of code I have below. I have looked around online, and I found a bunch of scripts that are designed to check all boxes in a form. My problem is that my checkboxes are created dynamically from a while loop (after reading from a database). None of the scripts I found have worked. I was hoping that someone here could guide me in the right direction as to how to fix this problem.
Thank you in advance.
SirBee
PS. I apologize if this is in the wrong location.
<?php
include 'connect.PHP';
print "<FORM NAME='badspirit' METHOD='POST' action='badspiritconfirm.php'>";
$query = mysql_query ("SELECT * FROM badspirit WHERE approved=0");
print "<font face=verdana size=2><table align=center width=800 cellspacing=3 cellpadding=3><tr><td colspan=6 align=center><FONT size=4 face='verdana'><b>Perpetual Motion's Spirit Score Screener</td></tr>
<tr bgcolor='#ccffff'><td><font size=2><b>Date Played</b></td><td><font size=2><b>Submitting Team</b></td><td><font size=2><b>Opponent</b></td><td><font size=2><b>Spirit Score</b></td><td><font size=2><b>Submitted By</b></td><td><font size=2><b>Submission Date</b></td></tr>";
$actualCount=0;
while($array=mysql_fetch_array($query)){
$actualCount=$actualCount+1;
$count=$array['report_number'];
$dd="<OPTION VALUE=''>Select</OPTION>";
if($array['spirit_score']=='1'){$dd.="<OPTION VALUE='1' SELECTED>1</Option>";}else{$dd.="<OPTION VALUE='1'>1</Option>";}
if($array['spirit_score']=='1.5'){$dd.="<OPTION VALUE='1.5' SELECTED>1.5</Option>";}else{$dd.="<OPTION VALUE='1.5'>1.5</Option>";}
if($array['spirit_score']=='2'){$dd.="<OPTION VALUE='2' SELECTED>2</Option>";}else{$dd.="<OPTION VALUE='2'>2</Option>";}
if($array['spirit_score']=='2.5'){$dd.="<OPTION VALUE='2.5' SELECTED>2.5</Option>";}else{$dd.="<OPTION VALUE='2.5'>2.5</Option>";}
if($array['spirit_score']=='3'){$dd.="<OPTION VALUE='3' SELECTED>3</Option>";}else{$dd.="<OPTION VALUE='3'>3</Option>";}
if($array['spirit_score']=='3.5'){$dd.="<OPTION VALUE='3.5' SELECTED>3.5</Option>";}else{$dd.="<OPTION VALUE='3.5'>3.5</Option>";}
if($array['spirit_score']=='4'){$dd.="<OPTION VALUE='4' SELECTED>4</Option>";}else{$dd.="<OPTION VALUE='4'>4</Option>";}
if($array['spirit_score']=='4.5'){$dd.="<OPTION VALUE='4.5' SELECTED>4.5</Option>";}else{$dd.="<OPTION VALUE='4.5'>4.5</Option>";}
if($array['spirit_score']=='5'){$dd.="<OPTION VALUE='5' SELECTED>5</Option>";}else{$dd.="<OPTION VALUE='5'>5</Option>";}
print "<input type='hidden' name='submitting_team_identifier".$count."' value='".$array['submitting_team_identifier']."'>
<input type='hidden' name='league".$count."' value='".$array['league']."'>
<input type='hidden' name='opponent_name".$count."' value='".$array['opponent_name']."'>
<input type='hidden' name='opponent_identifier".$count."' value='".$array['opponent_identifier']."'>";
print "<tr><td><FONT size=2>".$array['date_played']."</td><td><FONT size=2>".$array['submitting_team']."</td><td><FONT size=2>".$array['opponent_name']."</td>
<td><FONT size=2>
<SELECT NAME='spirit_score".$count."'>";
print $dd;
//This is where the checkboxes I want the checkall script to check
print "</SELECT>
</td><td><FONT size=2>".$array['submitted_by']."</td><td><FONT size=2>".$array['date_submitted']."</td>
<td><INPUT TYPE='checkbox' NAME='approve[]' VALUE='".$array['report_number']."'></td></tr>
<tr><td colspan=6><FONT size=2>".$array['comment']."</td><BR><BR></tr>";
}
if($actualCount!=0){print "<tr><td colspan=6 align=center><input type='submit' name='ApproveSpirit' value='Approve'></td></tr>";}else{
print "<tr><td colspan=6 align=center><i>No spirit scores in holding</i></td></tr>";}
print "</table>";
?>


Sign In
Create Account


Back to top









