javascript alert before php code -


page:content display.php

<td width="100"><a onclick="return confirmsubmit()" href="delete.php?id=<?php echo $row['id']; ?>&table=labour_details&return=content_display.php"><img src="../images/delete.png" border="0" alt="delete"></a></td> 

page:delete.php

if(isset($_get['id']) && isset($_get['table']))     {         $id=$_get['id'];         $tablename=$_get['table'];         $return=$_get['return'];             if($tablename=="labour_details")         {                     $sql=mysql_query("select * `labour_details` `id`='$id'");                     $row_1=mysql_fetch_array($sql);                     $labour_name= $row_1['labour_name'];                      if($labour_name!="")                     {                         $str=mysql_query("delete `labour_details` `id`='$id'");                         if($str)                         {                             header("location:$return?msg=record deleted successfully!&id=$id");                         }else{                             echo "problem in deleting :";                         }                     }          }  } 

my problem add alert before deleting record show javascript massage if allow delete record.

function confirmsubmit() {     var agree=confirm("are sure wish delete entry?");     if (agree)         return true ;     else         return false ; } 

this line show confirm dialogbox before redirect.

<a onclick="return confirm('are sure?')">...</a> 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -