Click here to Skip to main content
11,496,146 members (335 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
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

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
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2015
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