graham23s Posted July 22, 2007 Share Posted July 22, 2007 Hi Guys, For my site inbox i have a load of checkboxes besides each message to select then press delete , but i was wanting to place a "Select All" button besides the delete button to have all the boxes checked at the 1 time but not sure how to go about it heres my inbox: <?php // get the mail .../////////////////////////////////////////////////////////////// // get the users id first...//////////////////////////////////////////////////////// $query = "SELECT * FROM `membership` WHERE `username`='$member'"; $result = mysql_query($query) or die (mysql_error()); $row = mysql_fetch_array($result) or die (mysql_error()); // the users id in avariable...//////////////////////////////////////////////////// $id = $row['id']; // now get the pms.../////////////////////////////////////////////////////////////// $query2 = "SELECT * FROM `pms` WHERE `reciever_id`='$id' ORDER BY `date_added` DESC"; $result2 = mysql_query($query2) or die (mysql_error()); // if there are no messages...////////////////////////////////////////////////////// if (mysql_num_rows($result2) == 0) { // so theres no messages in the db then...////////////////////////////////////////// echo '<br /><b>No Messages Recieved Yet. (<a href="sentbox.php">Sent Box</a>)</b><br /><br />'; include("includes/footer.php"); exit; } else { // break out of php to make some html...//////////////////////////////////////// ?> <br /> <p>My Inbox <img src="images/msg_1.gif" border="0"></p> <table width="80%" border="1" bordercolor="#000000" cellspacing="0" cellpadding="2"> <tr> <td bgcolor="#E6E6FA"><P>Subject</td> <td bgcolor="#E6E6FA"><P>From</td> <td bgcolor="#E6E6FA"><P>Sent Date</td> <td bgcolor="#E6E6FA" ><P>Options</td> <td bgcolor="#E6E6FA" ><P>Delete</td> </tr> <?php } // back to the php.../////////////////////////////////////////////////////////////// echo '<form action="deletepm.php" method="post">'; // Now do a while loop to get all the results...//////////////////////////////// while ($row = mysql_fetch_array($result2)) { // define the variables...////////////////////////////////////////////////////// $id_2 = $row['id']; $read_yes_no = $row['read_flag']; $subject = $row['subject']; $sentdate = $row['date_added']; $sender_id = $row['sender_id']; if ($read_yes_no =='N') { $subject = '<strong>'.$subject.'</strong> (<font color="red"><b>NEW!</b></font>)'; } echo '<p><tr><td bgcolor="#FFFACD"><p><a href="readpm.php?id='.$id_2.'"><P>'.$subject.'</a></td>'; // get the username of the pm sender...///////////////////////////////////////// $query_3 = "SELECT id,username FROM `membership` WHERE id='$sender_id' LIMIT 1"; $result_3 = mysql_query($query_3) or die(mysql_error()); $row = mysql_fetch_array($result_3); // details in a variable as usual...//////////////////////////////////////////// $sender = $row['username']; $profile_id = $row['id']; echo '<td bgcolor="#FFFACD"><a href="user_details.php?id='.$profile_id.'"><p>'.$sender.'</a></td><P><td bgcolor="#FFFACD"><p>'.$sentdate.'</td><td bgcolor="#FFFACD"><p>[<a href="reply_pm.php?id='.$id_2.'&sender_id='.$sender_id.'">Reply</a>]-[<a href="sentbox.php">Sentbox</a>]</td><td bgcolor="#FFFACD"><input type="checkbox" name="delete[]" value="'.$id_2.'" /></td></tr>'; } echo " <tr> <td bgcolor=\"#004E98\" colspan=\"5\" align=\"right\"><input type=\"submit\" value=\"Delete\"></td> </tr> </table> </form> <br /><br />"; ?> any help and tips would be appreciated. thanks guys Graham Quote Link to comment Share on other sites More sharing options...
jaymc Posted July 22, 2007 Share Posted July 22, 2007 Its javascript, this should be in the javascript section checking this will check all checkboxes <input type='checkbox' name='CheckAll' value='' onclick='checkAll(this.form)' title='Select All Messages'> All of the checkboxes you want to use in this feature must be named list[] <input type=checkbox size=2 name='list[]'> <input type=checkbox size=2 name='list[]'> <input type=checkbox size=2 name='list[]'> Javasscript <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> function checkAll(f) { for (i = 0 ; i < f.elements.length; i++) { if ((f.elements.type == "checkbox") && (f.elements.name == "list[]")) { f.elements.checked = f.CheckAll.checked; } } return true; } </script> Quote Link to comment Share on other sites More sharing options...
graham23s Posted July 22, 2007 Author Share Posted July 22, 2007 Thanks mate. Graham Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.