confirm alert not working ....

Posted by user318068 on Stack Overflow See other posts from Stack Overflow or by user318068
Published on 2010-04-23T21:58:50Z Indexed on 2010/04/23 22:03 UTC
Read the original article Hit count: 202

Filed under:
|
|

I want the work of the Control Panel in my site for members ...

I designed the page is displayed all the registered members on my site

And i but it checkbox front each member name ,becuase it allowed to select multiple name then click delete button The following code works

but now i want confirm alert before delete code working

even , if clicked on ok the deletion is working , and if clicked on cancel the is not working ..

how i can work it ??

while($row = mysql_fetch_array($sql1))

{



    ?>
    <tr>
<td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['MemberID']; ?>"></td>
<td bgcolor="#FFFFFF"><?php echo $row['MemberName']; ; ?></td></tr>

<?php
} 

    ?>

<tr>
<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="delete"  onclick="javascript:return confirm('are you sure to delete this record???? ')"/></td>
</tr>


<?php


$delete = $_REQUEST['delete']; 
$checkbox = $_REQUEST['checkbox']; 
$count = count($_REQUEST['checkbox']); 
// Check if delete button active, start this 
if($delete){

    echo "<script language=\"Javascript\">\n";
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];


$sql = "Delete  FROM members where MemberID ='$del_id'";

$sq2 = "Delete FROM joinroom where MemberID ='$del_id'";

$result1 = mysql_query($sql);
$result2 = mysql_query($sq2);




echo "else {\n";
echo "alert ('Nothing deleted');\n }";
echo "</script>"; 


}
}

Thanks a lot.........

© Stack Overflow or respective owner

Related posts about confirm

Related posts about alert