Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

AJAX Delete multiple records with checkboxes?

9:00 pm on Sep 15, 2006 (gmt 0)

Full Member

10+ Year Member

joined:Feb 4, 2005
votes: 0

I'm a bit stumped as to how to approach this problem. I have a mail interface that shows message titles with a check box next to them which allows multiple messages to be deleted at once(very standard). But how can I do this AJAX style without a page refresh? Currently I just use a foreach $_POST['checkbox'] and loop through delete queries with PHP alone.

But I would like to use JS to grab all of the recordID's that need to be deleted and then somehow get them over to a php script.

Any guidance would be greatly appreciated.

8:03 pm on Sept 16, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 20, 2002
posts: 812
votes: 1

How about using a table row for each message, assigning it an "id" of {message no}. So <td id=""4> for example, with the checkbox of the same name.

Then for each click of a checkbox: add message no. to some array.

When submitted: send array as query string (delimited by whatever). Delete each message, then, when you get a successful server response, loop through array again and do id.innterHTML=""

Table rows may not be the best because they may leave an space when empty (depending on your table style). Perhaps <div>'s with <span>'s would be a better option, with the id on the div.

Any use?