1 回答

TA貢獻1853條經(jīng)驗 獲得超6個贊
生成 DOM 時,可以將數(shù)據(jù)屬性添加到“Confirm”鏈接,然后可以從單擊回調(diào)函數(shù)訪問該屬性。runConfirm
假設您要使用的id在中,這將給出:(為了清楚起見,僅顯示更改的部分)$rows['rid']
多姆生成
$displaybody .= "<tr>
<td>" . $rows['lname'] . ", " . $rows['fname'] . "</td>
<td>" . $rows['subject'] . "</td>
<td>" . $rows['days'] . " " . $rows['rstime'] . " - " . $rows['retime'] . "</td>
<td>" . $rows['note'] . "</td>
<td>
<a class='runConfirm' data-id='" . $rows['rid'] . "'>Accept</a>
<a href='home.php?decline=" . $rows['rid'] . "'>Decline</a>
</td>
</tr>"
彈出窗口處理(已更新)
$('.runConfirm').click(function(event){
// get the id you want to act on
var theId = $(this).data('id');
// ask user for confirmation
alertify.confirm('Are you sure to accept this request?',
// accepted
function(){
// go to the processing page
window.location = '/accept.php?rid=' + theId;
},
// declined
function(){
alertify.error('You clicked CANCEL');
}).set('closable', false);
});
你的第三個片段將進入.accept.php
您的代碼將:
使用行 ID 作為數(shù)據(jù)屬性呈現(xiàn)表
單擊“接受”時,提示用戶進行確認,并將其發(fā)送到“接受.php”頁面。
在服務器上運行后處理代碼,最終將用戶重定向到“home.php”
您可以在文檔中找到有關jQuery數(shù)據(jù)的更多信息:https://api.jquery.com/data/
- 1 回答
- 0 關注
- 80 瀏覽
添加回答
舉報