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
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();
}

本文标签: