Dynamically created javascript function question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mattcooper
Forum Contributor
Posts: 210
Joined: Thu Mar 17, 2005 5:51 am
Location: London, UK

Dynamically created javascript function question

Post by mattcooper »

Hi all... Hope you had a good Easter.

I'm using the following function to get a user to confirm deletion of a page:

Code: Select all

function confirmation() {
    var answer = confirm("Are you sure you want to delete this page?")
     if (answer){
              alert("Page will be deleted permanently");
			  window.location = "<? echo $_SERVER['PHP_SELF']."?PHPSESSID=".session_id()."&ezine_id=".$_GET['ezine_id']."&action=delete"; ?>";
					}
     else{
	 		  alert("Action cancelled");
			  //window.location = "<? echo $_SERVER['PHP_SELF']."?PHPSESSID=".session_id()."&ezine_id=".$_GET['ezine_id']; ?>";
         	        }
}
The call to this function goes in a link. What I am struggling with is how to get the JS function to specify which page to delete, perhaps by calling it thus: onClick="confirmation($page_id)".

Can anyone suggest how this may be possible?

Thanks in advance!
Post Reply