[英]php javascript confirm box for delete
下面的代碼在PHP中
echo "<input type='submit' name='delete' value='$t2[0]' class='delete_button' onclick='return confirm('Please Confirm Delete');'>"
我試圖創建一個刪除按鈕,當用戶單擊刪除按鈕時,它應該詢問確認。 但在這種情況下,它不起作用。
有沒有最好的方法來刪除帶有/或javascript並且沒有ajax的php中的確認
您的報價在這里破破爛爛;
onclick='return confirm('Please Confirm Delete');'>
改為使用;
onclick="return confirm('Please Confirm Delete');">
引號有誤,請改用此:
echo "<input type='submit' name='delete' value='$t2[0]' class='delete_button' onclick='return confirm(\"Please Confirm Delete\");'>"
你被再次打開單引號里面你出去你的屬性的confirm
。
好吧,在javascript中,您可以這樣做:
<input type='submit' name='delete' value='$t2[0]' class='delete_button' onclick='return askme();'> //javascript function function askme() { if(confirm("Are you sure you want to delete this..?")) { //delete someting } }
您可以嘗試此操作,非常簡單,並且可以正常工作。
<td> <a onClick="return confirm('DELETE: Are You sure ??');" href="member_delete?id=<?php echo $row['memID'];?>" >delete <i class="fa fa-trash-o" aria-hidden="true"></i></a></td> [DEMO][1]
我假設它在成員列表中。
您不能“將php代碼調用到jquery中”。 您唯一可以做的就是建立對服務器端PHP腳本的請求(AJAX),該腳本將接管您傳輸到腳本的各個參數,並產生輸出(使用echo或print),該輸出將自動在請求的回調。
使用jQuery就這么簡單
$.post('url/to/script.php', {parameter1: 'whatever', param2: 'something'}, function(response) {
// the output of the PHP script is available in the variable "response"
alert(response);
});
PHP腳本可以接管參數,對其執行任何操作並創建輸出
$param1 = $_POST["parameter1"];
$param2 = $_POST["param2"];
// do whatever you want with $param1 and $param2
// create some output using echo/print
echo "This will be transferred back to the calling Javascript";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.