can anyone heLp me

i need to send an id to a page through a javascript function but it wont work
he can't read the variable

 function confirm_delete() {    
var answer=confirm("Are You Sure You Want to Delete ?");
   if(answer==true)
     { 
        window.location="delete.php?id=$id"; 
      // alert(" Title Deleted");
     }
 else 
        return false ;  
        }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Correct, javascript doesn't know PHP.

Either grab the ID via javascript

window.location="delete.php?id=" + myElement.id;

or write it in with a full PHP script

window.location="delete.php?id=<? echo $id ?>";

Not seeing the rest of your script I don't know where you plan on getting the $id value ...

Hope this helps

hello try this code will work perfectly:

function confirm_delete(x) {
var answer=confirm("Are You Sure You Want to Delete ?");
if(answer==true)
{ 
		window.location.href="delete.php?id="+x;
		} 
		return;
}
This question has already been answered. Start a new discussion instead.