Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
JavaScript


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;
}
}
Posted

1 solution

HTML
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 (which is a HTTP Request variable) or $_REQUEST["var"]. It should work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900