我想将一个php变量传递给一个java脚本window.location,该脚本将用户从数据库中删除项目后返回到当前列表视图。我似乎无法得到正确的语法。将PHP变量传递给Java脚本window.location
代码:
function confirmation(a) {
var currString = "<? echo $currString ?>";
var answer = confirm("Are you sure you want to delete this item?")
if (answer){
alert("The item has been deleted")
window.location = "list.php?s='. $currString .'&=delete=true&id=" + a;
}
else{
alert("The item has not been deleted")
}
偏航,连接运算符混在一起。以及错位报价。 –
看来代码无法打开警报窗口。我的删除按钮什么都不做。 – pixelJockey
它似乎在这里工作:http://jsfiddle.net/sgEWz/ –