TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-01-2008, 05:37 PM   #1 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default What would you do?

Hey guys

Sorry to trouble you again but I would like your advice.

In my members control panel, I have the option to view the different codes of the images which they have uploaded, and to delete them.

I know I can literally go

Code:
<form method="bla" action="bla">
<input type="submit" name="delete_$id" value="delete image">
</form>
for each image, but surely that would be terribly a lot of code for such a simple thing?

But there's an extra layer on top of this: that is I want AJAX to load / do the deleting without the page reloading. Other wise I could have done it by a link with the id=$id, but would that work with AJAX?

Am I explaining myself well? :P

What would you do?

Gareth
Gareth is offline  
Reply With Quote
Old 03-01-2008, 07:58 PM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Personally, I would say that's one of the prime areas to use AJAX. After all, once you delete a single item via a text link, the page will reload and return to the very top of the page, making you scroll back down to where you deleted the item from (if you can remember). At the very least people should be using check-boxes to delete many at a time.

Use Prototype to do the AJAX call and actual deletion of the row upon success. You would be able to do it in 10 minutes, with 10 lines of code -- max!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 03-02-2008, 10:16 AM   #3 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default

So should I use a form / input button for each image rather than using a link (<a>)?
Thanks WH :)
Gareth is offline  
Reply With Quote
Old 03-02-2008, 06:36 PM   #4 (permalink)
The Contributor
 
flyingbuddha's Avatar
 
Join Date: Jan 2008
Location: Birmingham, UK
Posts: 60
Thanks: 10
flyingbuddha is on a distinguished road
Default

Personally, I don't like the delete one-at-a-time thing. When I build cms's I put a little checkbox next to the record so that multiple items can be selected and deleted at once, it also gives the opportunity to present an 'are you sure you want to delete these records' sort of prompt.
__________________
Pro. Geek
http://www.mikeholloway.co.uk
flyingbuddha is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:51 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design