Jump to content

Confirm Message Box


yash87

Recommended Posts

Can anyone help me with this delete confirm box. I have tried but somehow its not working. Can anyone help me with this?

 

Thankz.

 

html codes :

 

echo "<td><a href=delete.php?id=" . $rows['id'] ." onclick=\"return confirm(Are you sure?);\">Delete</a></td>";

 

delete.php :

 

<?php
include "config.php";
?>

<?php
$id=$_GET['id'];
?>

<script type="text/javascript">
<!--
function confirmation() {
    var answer = confirm('Are you sure you want to delete?')
    if (answer){
        $sql="DELETE FROM document WHERE id='$id'";
    }
    else{
        alert("Cancelled the delete!")
    }
}

</script> 

 

Link to comment
Share on other sites

Far be it from me to criticise, but I dont think as this is possible the way your structuring it, you cant use JS to manipulate php, but you CAN use php to manipluate JS.

 

JS is client side; php is server side; php renders text client side.

 

Rw

Link to comment
Share on other sites

Dude,

 

I guess u need to change your logic as follows:

 

In first file, separate JS code -

 

<script type="text/javascript">

function call_confirm(){

var answer = window.confirm ("Are you sure you want to delete?");

if (answer)

return true;

else

return false;

}

</script>

 

<?php

 

echo "<td><a href=delete.php?id=" . $rows['id'] ." onclick=\"return call_confirm()\">Delete</a></td>";

 

?>

 

In your delete.php, directly write query.

 

$id=$_GET['id'];

$sql="DELETE FROM document WHERE id='$id'";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.