Page 1 of 1

Javascript Return Function not recognised

Posted: Thu Sep 28, 2006 8:09 am
by NotOnUrNelly
Hi All,

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?

Code: Select all

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.

Many thanks
jamie

Posted: Thu Sep 28, 2006 8:26 am
by Jenk
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.