Javascript Return Function not recognised

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!

Moderator: General Moderators

Post Reply
NotOnUrNelly
Forum Commoner
Posts: 61
Joined: Wed Mar 24, 2004 4:45 pm

Javascript Return Function not recognised

Post 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
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post 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.
Post Reply