bleuler
asked on
using java script "confirm" with PHP
Hi,
I'm having some problem using Java Script and PHP together. I would like to have a link where I can delete a listed object from a DB. But the User should be asked if he really like to delete the record with a Java Script "confirm" Popup and if he choose no (Abort) the record will not be deleted.
My problem now is the record is deleted anyway doesn't matter if the user click "ok" or "Abort".
Please see my code below:
----------snip------------ ---------- ---------- ---------- ---------- ---------- ---------- ------
<?php
//some PHP code here......
?>
<script language="JavaScript">
<!--
if (confirm("Do you really like to delete the System ?")) {
<?
//delete the IP's from the Unit
$query = "delete from unitip where UNIT = '$id'";
mysql_query($query);
?>
break;
}
else{
break;
}
// -->
</script>
<?
//some more PHP code......
?>
----------snip------------ ---------- ---------- ---------- ---------- ---------- ---------- ------
do you have any idea how to make this work?
thanks & regards
Marc
I'm having some problem using Java Script and PHP together. I would like to have a link where I can delete a listed object from a DB. But the User should be asked if he really like to delete the record with a Java Script "confirm" Popup and if he choose no (Abort) the record will not be deleted.
My problem now is the record is deleted anyway doesn't matter if the user click "ok" or "Abort".
Please see my code below:
----------snip------------
<?php
//some PHP code here......
?>
<script language="JavaScript">
<!--
if (confirm("Do you really like to delete the System ?")) {
<?
//delete the IP's from the Unit
$query = "delete from unitip where UNIT = '$id'";
mysql_query($query);
?>
break;
}
else{
break;
}
// -->
</script>
<?
//some more PHP code......
?>
----------snip------------
do you have any idea how to make this work?
thanks & regards
Marc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Any particular reason for the "B" grade?
-Matt