Passing an array from PHP to Javascript

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



http://www.nabble.com/file/p19511848/untitled-1.gif 

N.B : I had to use anchor to replace the 'anchor tag' in the code below
because nabble was disallowing it
 
hi,

i am not a js guru so pls permit my naiveness. I need the 'delete' button on
the highlighted graphic to delete all checked pics for delete. My view has
the checkboxes as an array so i need to pass this array to a javascript
function.

Code:

<li class="remove_chk2"><input name="delete[]"  type="checkbox"
value="<?=$pics['PicID'];?>" /></li>
//$pics['PicID'] is from the db - the pic

<div class="page_button1">
<p>
<anchor href="javascript:confirmationMultiples('delete[]',
<?=$this->galleryID;?>, <?php echo "'" .  $type . "'"; ?>)">Delete</anchor>
</p>  
</div>

So once clicked ('delete' button) one would get a pop up asking if all
pictures should be deleted. But in actual fact the pictures are just flagged
inactive in the db table for the pics.

Code:

function confirmationMultiples(ID, Request, Type) {
    	var answer = confirm("Are you sure you want to delete the selected
pictures?")
	if (answer){
	
		alert("Entry Deleted")
		window.location = "http://mainevent.com/admin/galleries/delete-pics/pid/";
+ ID  + "/type/" + Type + "/id/" + Request;
	}
	else{
		alert("No action taken")
	}
}
// where request is the id for the gallery
// type is the type of gallery - event/venue gallery
// ID - should be the pics checked from the view on POST

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!!

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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux