hi everyone
i want to do something like in an inbox
if i click on a checkbox, it selects all checkboxes and it deletes the messages
and i can also select the message i wish to delete
how can i do that?
till now i have only been able to delete then one by one
delete from database
Moderator: General Moderators
The most common reply you'll get is 'What have you tried'. This forum is great for helping people that help themselves. You'll be hard pressed to get an answer without showing you've given it your best go.
With that said... what have you tried?
With that said... what have you tried?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
I think what you are looking for, is a javascript like this:
http://www.somacon.com/p117.php
Then in the actual form, each checkbox-input would have to be named as an a array, eg:
Which makes it pretty easy to loop through emails:
http://www.somacon.com/p117.php
Then in the actual form, each checkbox-input would have to be named as an a array, eg:
Code: Select all
<form ..>
<input type="checkbox" name="email[]" value="1"/> //value being the id of an email
<input type="checkbox" name="email[]" value="2"/>
</form>Code: Select all
foreach($_POST['email'] as $email_id)
{
//delete email with id == $email_id
}- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
This......is not necessarily supported by all browsers. To ensure it is put values in the subscripts. Like this:
Yeah you will have to use some JavaScript. To make all the checkboxes select. Add an onchange event to the primary checkbox (the one that will trigger all the others to check or uncheck) and in that event obtain the other checkboxes and iterate over them setting their values to true or false depending on the check value of the primary checkbox the event is attached to. Obviously if you don't know JS this isn't going to mean anything to you 
Code: Select all
<input type="checkbox" name="email[]" value="1"/> //value being the id of an email
<input type="checkbox" name="email[]" value="2"/> Code: Select all
<input type="checkbox" name="email[0]" value="1"/> //value being the id of an email
<input type="checkbox" name="email[1]" value="2"/>