Javascript:无法在确认消息后删除


Javascript: Can't delete after the Confirmation Message

这是我的方案:

我有一个表单,main_play.php,它是所有播放列表的列表,然后当我单击单选按钮时,它会弹出一条确认消息,然后它将继续进入play_delete的形式......继续下一页正在工作...

但是在play_delete.php所有变量中,所有变量都已经是空的......但是,当我不使用确认消息时,可以将其删除,并且变量也会在play_delete中传输......

这是我的变量:

$get_ID = $_POST['deletePlaylist'];

这是我的PHP代码:

<input type="radio" name="deletePlaylist[]" class="chk_boxes1" value="<?php echo $row['id']; ?>"<?php echo ($_POST['deletePlaylist[]'] == $row['id'] ? 'checked=" checked"' : ''); ?> onclick='confirmation()'>

这是我的javascript:

<script>
function confirmation() {
    var answer = confirm("Are you sure you want to delete?")
    if (answer){
        window.location = 'play_delete.php';
    }
    else{
        alert("Thanks for sticking around!")
    }
}
</script>

有没有办法将 php 中的数据传输到 javascript,然后将 javascript 传输到下一页?

提前感谢!

替换

  window.location = 'play_delete.php';

 document.formname.action = 'play_delete.php';
 document.formname.submit();

其中 formname 是页面上显示所有播放列表单选按钮的表单的名称。

试试这个它会起作用

<script>
    function confirmation(value) {
        var answer = confirm("Are you sure you want to delete?")
        if (answer){
            window.location = 'play_delete.php?data='+value;
        }
        else{
            alert("Thanks for sticking around!")
        }
    }
    </script>
    <body>
    <input type="radio" name="radio" value="uniqvalue" id="name" onclick='confirmation(this.value);'/>
    </body>

看看这个将PHP变量转移到javascript变量:

如何在 JavaScript 或 jQuery 中访问 PHP 变量