admin管理员组文章数量:1415145
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 Function:
function MyReason(){
var reason = prompt("Reason");
}
PHP Snippet:
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
and save it in DB.
Thanks Mates.
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 Function:
function MyReason(){
var reason = prompt("Reason");
}
PHP Snippet:
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
and save it in DB.
Thanks Mates.
Share Improve this question edited Aug 19, 2014 at 5:47 Husen 9351 gold badge6 silver badges18 bronze badges asked Aug 19, 2014 at 5:40 OranjeOranje 671 silver badge9 bronze badges 3- There're 2 options. Use ajax or submit form. – manassorn Commented Aug 19, 2014 at 5:43
- how can I use submit in this @manassorn – Oranje Commented Aug 19, 2014 at 5:48
- I'd remend you go for the jQuery-library to make Ajax easier. Take a look at this really simple and basic tutorial: [Link]ajaxtutorial/index.php/2010/03/03/… – Atanu Commented Aug 19, 2014 at 5:58
2 Answers
Reset to default 3You 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>
try this code:
function MyReason(){
var reason = prompt("Reason");
document.getElementById('hiddenNameField').value = reason;
document.forms(0).submit();
}
本文标签:
版权声明:本文标题:How to get the value from Javascript Prompt Box and Pass it into PHP variable to be able to save in SQL? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745197007a2647190.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论