我需要按钮onClick的帮助。

<button type="button" id="1" onclick="this.disabled=true; ^FUNCTION TO UPDATE^">
<button type="button" id="2" onclick="this.disabled=true; ^FUNCTION TO UPDATE^">
<button type="button" id="3" onclick="this.disabled=true; ^FUNCTION TO UPDATE^">


使用此代码,我可以禁用按下的按钮,但是我还需要更新发送ID的数据库中的信息,如下所示:

UPDATE reservation SET status='approved' WHERE id=^ID OF THE CLICKED BUTTON^


我需要将其加载到同一页面中,而不用POSTGET发送。

最佳答案

为此使用ajax调用,例如:

$.get('update_reservation.php', {id: 1});


有关更多信息,请参见http://api.jquery.com/jQuery.get/

关于php - 使用onclick按钮更新数据库信息,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6559868/

10-11 03:08
查看更多