如何从Javascript Prompt Box中获取值并将其传递到PHP变量以能够保存在SQL中? [英] How to get the value from Javascript Prompt Box and Pass it into PHP variable to be able to save in SQL?

查看:69
本文介绍了如何从Javascript Prompt Box中获取值并将其传递到PHP变量以能够保存在SQL中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题,我希望我的脚本执行此操作: -在用户拒绝条目(服务器端)之前,系统必须提示文本框,询问他们为什么要拒​​绝条目的原因.然后保存输入到MySQL服务器的原因.

Here is my problem, I want my script to do this: -before the user reject entry(server side), system must prompt text box asking the reason why they want to reject it. and then save the reason they input to MySQL server.

JavaScript函数:

Javascript Function:

function MyReason(){
    var reason = prompt("Reason");
}

PHP代码段:

echo "<td> <a href=changeStatReject.php?id=" . $row['id'] . ">"  . "<img src='media/reject.png'>" . "</a></td>";

从这里,我想获取提示框的值并将其传递给

From Here, I want to get the value of prompt box and pass it to

changeStatReject.php

changeStatReject.php

并将其保存在数据库中.

and save it in DB.

感谢伙伴.

推荐答案

您可以将值发送到表单中的隐藏输入并提交.

You can send value to hidden input in the form and submit it.

function MyReason(){
    var reason = prompt("Reason");
    document.getElementById("reason").value = reason;
    document.getElementById("form").submit();
}

<form id="form">
    <input type="hidden" id="reason" />
</form>

这篇关于如何从Javascript Prompt Box中获取值并将其传递到PHP变量以能够保存在SQL中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆