I see exactly what you have been saying - again my mind was too saturated to
see clearly! :(

Anyway, just to reply one some of the questions you asked.

The intention is that the user can either delete the picture indivually
using the delete button next to each picture or select all and delete all. -
but at the same time the user could deselect some pics - the intention is
such that the user can delete a lot of pics at once.

The reason my URL looks like am using a GET method is because the delete
button is not a button but a link. the full view of my design is this just
to explain a bit more:

http://www.nabble.com/file/p19520252/untitled-2.gif 

I see what am doing wrong now - just to butress on your suggestions, i need
to make that 'delete' button an actual button not a link - so the form can
actually get submitted naturally via the POST method. From my controller
retrieve the delete[] and iterate for deletion.

I see clearly now. I think i got confused along the line while coding. 



Colin Guthrie-6 wrote:
> 
> dele454 wrote:
>> Thanks for the tips. But i CAN'T apply any of them now. The design has
>> been
>> approved and i need to i implement things as they are. 'Over engineered'
>> - I
>> dont care. As long my code works as expected. I simply want to pass my
>> PHP
>> array into my javascript function. - very simple code i dont see why i
>> need
>> to implement a library just for that.
> 
> I wasn't suggesting you change the visual design, or do you mean a 
> different kind of design?
> 
> Do you allow the user to select some pictures and not others? If so your 
> delete multiple button does not work as you pass the *gallery* id, not 
> the list of selected picture ids.
> 
> If you do not allow the user to select some and not others, then there 
> is no point in producing the individual checkboxes next to the pictures, 
> just use a "Delete gallery" button and be done with it.
> 
> I've explained how you would implement a form that could happily accept 
> an array of selected picture ids so there is little more help I can give 
> you are not going to follow that route.
> 
> I have explained also how to pass a PHP array into JS, but as I said 
> before, this is almost certainly not what you want to do to achieve this 
> kind of interface.
> 
> What you actually have is a list of selected items in javascript and you 
> want to pass that back to PHP as an array! it's precisely the other way 
> around. This is easily possible and by naming the checkboxes as you have 
> you are very much on the right route, but you should allow the form to 
> be submitted naturally, do not try to force it via a window.location = 
> 'blah' hack. If you insist on doing this then you will have to cycle 
> through the elements of the form with the specific name and append 
> "&delete[]=ID" multiple times to your URL (or /delete/ID multiple times 
> if you've wrapped up the URL parsing in a ZF route appropriately).
> 
> But trust me. Use a form. Use POST, submit it normally with an onsubmit 
> confirmation function. (you could also submit the form by calling the 
> submit() method on the form itself, but this will prevent your interface 
> working on browsers which have JS disabled - my recommended way would 
> work just find without javascript, albeit sans a warning).
> 
> Col
> 
> 
> 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/]
> 
> 
> 


-----
dee
-- 
View this message in context: 
http://www.nabble.com/Passing-an-array-from-PHP-to-Javascript-tp19511848p19520252.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to