ecopetition Posted August 12, 2009 Share Posted August 12, 2009 Hi there, I'm trying to make a private messaging system and wondered if you could advise me how to select multiple messages at once and perform actions on the selected messages. Here's the HTML code for the "inbox" page: <form action="messages.php?m=delete_pm" method="post"> <table border="0" cellspacing="1" cellpadding="2"> <tr> <td>Subject</td> <td>From</td> <td>Time Received</td> <td>Actions</td> </tr> <tr> <td><a href="ucp.php?m=read_private_message&id=10">message test 2</a></td> <td><span class="capitalise"><a href="profile.php?u=4">Poster</a></span></td> <td>12 Aug 2009 22:11</td> <td><input type="checkbox" name="pm[]" value="10" /></td> </tr> <tr> <td><a href="ucp.php?m=read_private_message&id=8">message test</a></td> <td><span class="capitalise"><a href="profile.php?u=4">Poster</a></span></td> <td>12 Aug 2009 22:11</td> <td><input type="checkbox" name="pm[]" value="8" /></td> </tr> <tr> <td><a href="ucp.php?m=read_private_message&id=6">hello</a></td> <td><span class="capitalise"><a href="profile.php?u=4">Poster</a></span></td> <td>12 Aug 2009 20:59</td> <td><input type="checkbox" name="pm[]" value="6" /></td> </tr> </table> With Selected Messages: <select name="mode"> <option value="delete">Delete</option> <option value="move_2">Move to folder '2'</option> </select> <input type="submit" name="submit" value="Submit" /> </form> The final column of each row contains a checkbox with a value/id unique to the message in question. This is where I get lost, I don't know how to utilise the data sent to the form (seeing which checkboxes are selected and the "with selected messages" mode). Can anyone please help me by pointing me in the right direction? Thanks a lot, Ecopetition Link to comment https://forums.phpfreaks.com/topic/169990-multiple-checkbox-select-actions/ Share on other sites More sharing options...
MatthewJ Posted August 12, 2009 Share Posted August 12, 2009 You should be able to just loop through the checkbox values since they are being stored as an array. foreach($_POST['pm']) { //Do what you want to do with each value } Link to comment https://forums.phpfreaks.com/topic/169990-multiple-checkbox-select-actions/#findComment-896757 Share on other sites More sharing options...
sawade Posted August 12, 2009 Share Posted August 12, 2009 <input type="checkbox" name="pm[]" value="6" /> <input type="checkbox" name="pm[]" multiple="multiple" value="6" /> Multiple allows for more than one checkbox to be selected at a time. Link to comment https://forums.phpfreaks.com/topic/169990-multiple-checkbox-select-actions/#findComment-896840 Share on other sites More sharing options...
MatthewJ Posted August 13, 2009 Share Posted August 13, 2009 <input type="checkbox" name="pm[]" value="6" /> <input type="checkbox" name="pm[]" multiple="multiple" value="6" /> Multiple allows for more than one checkbox to be selected at a time. I think that's for multiple select menus Link to comment https://forums.phpfreaks.com/topic/169990-multiple-checkbox-select-actions/#findComment-896846 Share on other sites More sharing options...
sawade Posted August 13, 2009 Share Posted August 13, 2009 <input type="checkbox" name="pm[]" value="6" /> <input type="checkbox" name="pm[]" multiple="multiple" value="6" /> Multiple allows for more than one checkbox to be selected at a time. I think that's for multiple select menus Works on checkboxes. I use it all the time. Never an issue. Link to comment https://forums.phpfreaks.com/topic/169990-multiple-checkbox-select-actions/#findComment-896855 Share on other sites More sharing options...
MatthewJ Posted August 13, 2009 Share Posted August 13, 2009 <input type="checkbox" name="pm[]" value="6" /> <input type="checkbox" name="pm[]" multiple="multiple" value="6" /> Multiple allows for more than one checkbox to be selected at a time. I think that's for multiple select menus Works on checkboxes. I use it all the time. Never an issue. Um... pretty sure it isn't doing anything being there as checkboxes allow multiple selections inherently... Create 5 checkboxes on a page and select multiple boxes, I'm sure it won't be a problem even without the extra attribute as I have been building html forms for 10 years and have never used it once Link to comment https://forums.phpfreaks.com/topic/169990-multiple-checkbox-select-actions/#findComment-897306 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.