Click here to Skip to main content
Rate this: bad
good
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
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Afzaal Ahmad Zeeshan 82
4 Sergey Alexandrovich Kryukov 75
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


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