Re: Embedded php in javascript

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:

<form name=myform>
<input type=button value="Delete Venue" onClick="if(confirm('Are you sure
you want to delete ID # <? echo "$UID"; ?>? There is no undo.'))
{alert('Value deleted<? mysql_query("DELETE from table where ID = '$UID'");
?>')}
else
{alert('no changes')}">
</form>

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux