Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AJAX Delete by Checkbox?

Status
Not open for further replies.

alphacooler

Programmer
Aug 29, 2005
73
US
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.
 
Personally, I would recommend using a library to perform your AJAX functions (why reinvent the wheel?), but that's my two cents.

If you were using prototype:

Code:
var params = Form.serialize('checkboxformname');
new Ajax.Request('youphpscript.php', {
   method: "post",
   postBody: params,
   asynchronous: true
});

You can even add more code to add a progress indicator.

Let us know your results!

X
 
Xagte,

Thanks so very much. That worked out beautifully. I had never given the prototype lib a chance because most of my AJAX is pretty straightforward and I thought it would be overkill, but I can put up with an extra 40k on some of my scripts if it saves me THIS much work!

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top