doulutian4843 2016-03-03 07:05
浏览 38
已采纳

如何在包含javascript确认框的变量中保存echo语句?

I have following code

echo '<script type="text/javascript">confirm("Are You Ready To Restore ?");</script>';

Now a confirm box will appears as follows: enter image description here

So when user click on ok the process will continue otherwise it will stop further processing as it cancel it. I want to apply if condition on OK and cancel button . How to save this echo result in variable so that i can apply if condition on it .

  • 写回答

2条回答 默认 最新

  • dongzanghong4379 2016-03-03 07:14
    关注

    How to save this echo result in variable so that i can apply if condition on it .

    You can't do that in one http request. You can put Javascript code in your PHP variables, display it but your PHP code will not get the answer to javascript prompt unless you initiate another request, usually via ajax. Or you can take that conditional code to Javascript completely.

    PHP is already asleep by the time JavaScript stats working.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?