将PHP变量传递给Java Script window.location [英] Pass PHP Variable into Java Script window.location
本文介绍了将PHP变量传递给Java Script window.location的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将php变量传递到java脚本window.location,该窗口在从数据库中删除项目后将用户返回到当前列表视图。我似乎无法使语法正确。
I am trying to pass a php variable into a java script window.location that returns a user to the current list view after deleting an item from the database. I can't seem to get the syntax correct.
代码:
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")
}
推荐答案
试试这个:
function confirmation(a) {
var currString = "<?php 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");
}
这篇关于将PHP变量传递给Java Script window.location的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文