How to get the value from Javascript Prompt Box and Pass it into PHP variable to be able to save in SQL? - Stack Overflow

Here is my problem, I want my script to do this:-before the user reject entry(server side), system mus

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
Add a ment  | 

2 Answers 2

Reset to default 3

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>

try this code:

function MyReason(){
    var reason =  prompt("Reason");
    document.getElementById('hiddenNameField').value = reason;
    document.forms(0).submit();
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745197007a4616143.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信