tqla Posted March 11, 2010 Share Posted March 11, 2010 Hello. Can someone help me get this to work? The popup works when I put a simple url in the Action but stops working when I add the long URL with the $_GET vars. Nothing happens, no popup. I've tried a lot of things but can't get it to work. Here is my popup code <SCRIPT LANGUAGE="JavaScript"> function popup(w,h,p){ var left = (screen.availWidth/2) - (w/2); var top = (screen.availHeight/2) - (h/2); window.open(p,'Comp','width='+w+',height='+h+',scrollbars=0,status=0,menubar=0 left='+left+', top='+top) } </SCRIPT> And here is my Form Action <form id="form1" name="form1" method="get" action="javascript:popup(1050,650,'http://www.mywebsite.com/comparison.php?s1=$_GET['s1']&s2=$_GET['s2']&s3=$_GET['s3']&s4=$_GET['s4']&s5=$_GET['s5']&s6=$_GET['s6']')"> Quote Link to comment Share on other sites More sharing options...
jl5501 Posted March 11, 2010 Share Posted March 11, 2010 You do not show where those $_GET variables come from, or what sort of values they contain. One thing that will help, is if you test this in firefox with the error console open, it will reveal where it is having issues. Quote Link to comment Share on other sites More sharing options...
tqla Posted March 11, 2010 Author Share Posted March 11, 2010 The GET's all work fine if I omit the javascript:popup() syntax. I think the apostrophes in the long url are mucking it up. I will look into escaping the url. Quote Link to comment Share on other sites More sharing options...
jl5501 Posted March 11, 2010 Share Posted March 11, 2010 Yes, this is what I suspected, and the error console in firefox will confirm that Quote Link to comment Share on other sites More sharing options...
tqla Posted March 11, 2010 Author Share Posted March 11, 2010 Okay, when I escape the apostrophies the popup now pop's up but the GET's are not getting. They appear like this: comparison.php?s1=$_GET['s1']&s2=$_GET['s2']&s3=$_GET['s3']&s4=$_GET['s4']&s5=$_GET['s5']&s6=$_GET['s6'] Is there a special way to get the GET to work in a JS popup? Without the javascript the GET's work fine. Quote Link to comment Share on other sites More sharing options...
jl5501 Posted March 11, 2010 Share Posted March 11, 2010 The $_GETs have to be echoed in <?php ?> tags Quote Link to comment Share on other sites More sharing options...
tqla Posted March 11, 2010 Author Share Posted March 11, 2010 tried /comparison.php?s1=<?php echo $_GET['s1']?>' and the resulting popup url reads "?s1=" . The GET var is not passing. I tried POST too. It appears that the method="get" is bypassed when using the popup. . Quote Link to comment Share on other sites More sharing options...
jl5501 Posted March 11, 2010 Share Posted March 11, 2010 I think there is some confusion here if the popup is another page like xyz.php then you will need to pass the variables to it in the normal manner in the url, or use the session. So you will need to have xyz.php?var1=blah ... Quote Link to comment Share on other sites More sharing options...
XeNoMoRpH1030 Posted March 11, 2010 Share Posted March 11, 2010 I also believe there is confusion. I get the impression you are trying to use values in inputs to fill those values? If that's the case, PHP isn't even used. Javascript can definitely grab those values though and compile a URL with the variables. Quote Link to comment Share on other sites More sharing options...
tqla Posted March 11, 2010 Author Share Posted March 11, 2010 Yes, I am using a form and PHP is passing the vars using $_GET to creat the url for the comparison.php page. It works fine. But when I try to open comparison.php in a popup window using the js popup function the $_GET vars are not passed. So, judging by what you all are saying, JS needs to do the GET work and not PHP. I will go back and start over using soley JS to process the form and create the URL for the comparison page. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.