Embedded php in javascript

Embedded php in javascript

am 23.03.2007 02:38:35 von Onochie Anyanetu

------=_Part_119387_6571285.1174613915671
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi, I am trying to create a pop up alert warning for deleting an entry in my
database. What I have is:


? There is no undo.'))
{alert('Value deleted ?>')}
else
{alert('no changes')}">


The problem here is that the embedded php is run regardless of if the user
clicks no, for example if i put php in both the if and the else they will
both be executed. So does anyone have and idea how to make this work or
another workaround?

------=_Part_119387_6571285.1174613915671--

Re: Embedded php in javascript

am 23.03.2007 03:45:46 von dmagick

Onochie Anyanetu wrote:
> Hi, I am trying to create a pop up alert warning for deleting an entry
> in my
> database. What I have is:
>
>


> ? There is no undo.'))
> {alert('Value deleted > ?>')}
> else
> {alert('no changes')}">
>

>
> The problem here is that the embedded php is run regardless of if the user
> clicks no, for example if i put php in both the if and the else they will
> both be executed. So does anyone have and idea how to make this work or
> another workaround?

Have the confirm take you to another page where you execute the query.

PHP knows nothing of javascript and vice versa - if you include php
inside a javscript "if" it means nothing.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Embedded php in javascript

am 23.03.2007 04:42:10 von Charles Morris

Chris is right, you also must understand that javascript runs
client-side, (In the browser),
and PHP is server-side (runs on the server).

You can generate javascript with PHP, but hardly the other way around ;).

--
Charles Morris
cmorris@cs.odu.edu

Network Administrator, Software Developer

iSTART Research Assistant,
X-CS Systems Group Old Dominion University
http://15037760514/~cmorris

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Embedded php in javascript

am 26.03.2007 03:48:43 von bedul

i think u have mistaken using javascript
----- Original Message -----
From: "Onochie Anyanetu"
To:
Sent: Friday, March 23, 2007 8:38 AM
Subject: [PHP-DB] Embedded php in javascript


> Hi, I am trying to create a pop up alert warning for deleting an entry in
my
> database. What I have is:
>
>


> ? There is no undo.'))
> {alert('Value deleted '$UID'");
> ?>')}
> else
> {alert('no changes')}">
>

remember one things.. by click it u execute the script to del.. u should add
this
return false;

==========================
>
> The problem here is that the embedded php is run regardless of if the user
> clicks no, for example if i put php in both the if and the else they will
> both be executed. So does anyone have and idea how to make this work or
> another workaround?
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php