PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Can anyone help me, I have a button that refreshes the page and sends a variable through the url. The code basically deletes the record displayed next to the button. The code is below, I have added some javascript to try to confirm the record should be deleted. My program does not seem to be recognising the javascript. Does anyone know what I am doing wrong?
if ($Entry == "deleteClient"){
{
?>
<script language="JavaScript" type="text/JavaScript">
return confirm('Are you sure you want to delete this Interview?')
</script>
<?
sql_return("delete from tblClients where CustomerID='$ClientID'");
}
I am finding the record is being deleted regardless of the Javascript being in place.
You can't interrelate between Javascript and PHP like that. The PHP parser will execute all php code on a page before the user agent sees any of it. Javascript is a client side scripting tool, thus it is execute by the client and not the server.
i.e. The php will execute before any of your javascript reaches the user.