将提示框变量从javascript传递给php
您好我有问题将javascript提示框的变量传递给php脚本。任何人都可以在我的下一个脚本中找到我所犯的错误..谢谢
Hello I am having problem to pass the variable of javascript prompt box to php script . can any one find which mistake I have done in my following script .. Thank you
function confirmDelete()
{
var del = confirm(请在删除之前将配置文件分配给新名称);
if (del == true)
{
var x = prompt(在这里输入新的CIE名称。,输入名称) );
if(x!= null&& x!=)
{
window.location.href = delete.php?var =+ x;
}
if(x == null || del == false || x ==)
{
alert(抱歉!你无法在不指定其他CIE的情况下删除个人资料);
返回false;
}
}
else
{
返回false;
}
}
function confirmDelete()
{
var del = confirm("Please assign the profile to new name before deleting");
if(del==true)
{
var x=prompt("Enter here the new CIE name.","enter name");
if(x!=null && x!=" ")
{
window.location.href="delete.php?var="+x;
}
if(x==null || del==false || x==" ")
{
alert("Sorry!You can not delete profile without assigning to the other CIE");
return false;
}
}
else
{
return false;
}
}
In your JS code (removed the extra space):
if(x!=null && x!=" ") should be if(x!=null && x!="")
and
if(x==null || del==false || x==" ") should be if(x==null || del==false || x=="")
It seems alright, but i'm confused why you couldn't get the variable in your PHP script. Try to print/check
_REQUEST (这是一个HTTP请求变量)或
_REQUEST (which is a HTTP Request variable) or
_REQUEST [var] 。它应该可以工作。
_REQUEST["var"]. It should work.