Click here to Skip to main content
12,074,441 members (62,097 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: 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("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 19-Feb-13 22:22pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160208.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100