dele454 wrote:
WHat exactly am i doing wrong??? currently my URL reads as
Code:
http://mainevent.com/admin/galleries/delete-pics/pid/delete[]/type/event/id/313
I think the main hassle is from posting the form getting all the checkboxes
in array delete[] to the js and then to the controller that then initiates
the delete by reading the parameter from the URL, iterating over the array
variable etc.
Pls help!!
As a general bit of advice, I would never do any destructive with GET
requests (e.g. manipulating the URL and redirecting via window.location).
If you need to do it fully in javascript, look at some kind of AJAX call
that can do POSTs (my preference is jquery, but dojo may be preferred
with ZF...)
But, really this is over engineered and you should look at a different
approach.. here is my hint:
1. Just use a normal form. Have all the checkboxes and the "Delete
Selected" button on the same form.
2. POST said form (do not use GET).
3. If you want to give the user a chance to backout with a javascript
confirmation, define an onsubmit handler for the form. Depending on what
this handler returns, the browser will either process or cancel the form
submission. So you in it's most basic form:
<form method="post" action="myurl" onsubmit="return confirm('Are you
sure?');">
That should be better!
Oh, and just for future reference if you want to pass arrays or generic
classes to javascript from php, you want to look into JSON and
specifically the json_encode() function (although there may be a ZF
wrapped up version - not sure!)
Col
--
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/
Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]