由网友(选择离殇)分享简介://this is in phpfunction msgbox($msg, $type){if ($type == "alert"){// Simple alert window?>...
//this is in php
function msgbox($msg, $type)
{
if ($type == "alert")
{
// Simple alert window
?> <script language="JavaScript"> alert("<? echo $msg; ?>"); </script> <?
}
elseif ($type == "confirm")
{
// Enter Confirm Code Here and assign the $result variable for use
// Should include "OK" and "Cancel" buttons.
?>
<script language="JavaScript">
if (confirm("<? echo $msg; ?>"))
{
<? $result == "ok"; ?>
}
else
{
<? $result == "cancel"; ?>
}
</script>
<?
}
}
if ($page_title->exists())
{msgbox("page exists,do you want to delete", "confirm");
}
if ($result == "ok")
//code..
问题是, $结果
不是从确认框我想读的值,因为如果子句不被执行,程序流程是怎么回事哪里会去没有if子句。
The problem is that $result
is not reading the value from the confirm box I think because the if clause is not being executed and the program flow is going where it would go without the if clause.
推荐答案
您不能混用服务器端code(PHP)与客户端$ C C这样$。 对于JavaScript来改变PHP的状态,你需要做一个HTTP调用(AJAX经常使用)。
You cannot mix server-side code (PHP) with client-side code that way. For javascript to change PHP-state, you need to make a HTTP-call (AJAX is often used).
您需要阅读PHP的教程,并确保你掌握的概念。
You need to read a PHP-tutorial and make sure you grasp the concepts.
相关推荐
最新文章