douhui3760 2010-01-23 07:50
浏览 50

将JavaScript确认框的结果分配给PHP变量

//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..

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.

  • 写回答

3条回答 默认 最新

  • dongqi6964 2010-01-23 08:16
    关注

    You are using short tags, make sure that they are turned on from php.ini file otherwise php code won't execute in your code.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100