亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 sweetalert2 重定向到另一個網站并獲取信息

使用 sweetalert2 重定向到另一個網站并獲取信息

PHP
蝴蝶刀刀 2023-07-21 15:57:14
所以我想使用 sweetalert2 重定向到,例如使用 ?ID= 的內容刪除.php。我該如何放入東西?這是我的代碼。第一個是在 php echo html 中,這樣我就可以輸入 sql 數據庫中的所有內容。echo'<td style="text-align: center;"> <div class="btn-group dropup"><button class="btn btn-info dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Action</button>   <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">      <a class="dropdown-item" href="edit_form.php?ID='.$operatives['ID'].'">Edit</a>      <a class="dropdown-item red" onclick="oof("'.$operatives['ID'].'")" href="#">Purge</a>   </div></div> </td>'這是 sweetalert2 代碼<script>function oof(id){    var MyId = id;    Swal.fire({  title: 'Are you sure?',  text: "You will be purging this person's account.",  icon: 'warning',  showCancelButton: true,  confirmButtonColor: '#d33',  cancelButtonColor: '#3085d6',  confirmButtonText: 'Yes, purge account'}).then((result) => {  if (result.value) {    window.location = "deleting.php?ID="+MyId;  }})}</script>假設ID是4,如果可能的話,我希望它可以重定向到deleting.php?ID=4。謝謝你!是否可以從 GET 信息激活 sweetalert2?如何激活?
查看完整描述

1 回答

?
牧羊人nacy

TA貢獻1862條經驗 獲得超7個贊

除了 PHP 之外,JavaScript 中的字符串連接不是用點來完成的。您必須使用+字符來連接。因此,您的代碼必須類似于以下示例;


window.location = "deleting.php?ID=" + id;

可以通過 GET 參數將 SweetAlert 作為 JavaScript 庫激活。只需使用URLSearchParams本機對象即可。


const urlParams = new URLSearchParams(window.location.search);

const myParam = urlParams.get('myParam');


if (myParam) {

    // initialize here

}


查看完整回答
反對 回復 2023-07-21
  • 1 回答
  • 0 關注
  • 168 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號