Welcome to WebmasterWorld Guest from 23.22.46.195

Forum Moderators: open

AJAX Delete multiple records with checkboxes?

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

10+ Year Member



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 Sep 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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?

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month