ThePsion5 Posted March 20, 2006 Share Posted March 20, 2006 Hi,I'm trying to write a small function in javascript that creates a popup window and passes GET values into it. The GET values are already included via PHP code, but javascript doesn't seem to like this. I get an error message that reads the following: Error: invalid assignment left-hand sideSource Code:popup(related.php?id=1&field=clients)-----------------------------^ Here's the code for the actual javascript function: function popup(url){ related = window.open (url, "related", "location=0,status=0,scrollbars=1, toolbar=0, menubar=0, directories=0");} and here's how I call the function in PHP: $url = "related.php?id=$Client->clientID&field=$table";print "<td><a onclick=\"popup($url)\">$Client->numKeywords</a></td>"; I don't think I'm doing anything incorrectly, any idea as to what might be up? Thanks in advance! Link to comment Share on other sites More sharing options...
Webworldx Posted March 20, 2006 Share Posted March 20, 2006 don't you wantpopup('$url') instead? Link to comment Share on other sites More sharing options...
ThePsion5 Posted March 24, 2006 Author Share Posted March 24, 2006 Enclosing it in single quotes didn't have any effect, sadly. It seems to take issue with the second equal sign... Link to comment Share on other sites More sharing options...
ThePsion5 Posted March 24, 2006 Author Share Posted March 24, 2006 I decided to change my approach and make my javascript function inside of the new window and just resize it appropriately, but this still leaves me wondering...how does one retrieve GET values in javascript? Link to comment Share on other sites More sharing options...
scott100 Posted March 24, 2006 Share Posted March 24, 2006 This opens a new window with javascript bassed on the url passed from php. <head><script>function popup(url){ related = window.open (url, "related","location=1,status=0,scrollbars=1, toolbar=0, menubar=0, directories=0");}</script></head><body><?php ini_set ('display_errors', 1);error_reporting (E_ALL & ~E_NOTICE);$url = "related.php?id=$Client->clientID&field=$table";print '<table border="1"><tr><td><a onclick=\'popup("' .$url. '")\'>Click Me</a></td></tr></table>';?></body> Does this solve your problem? Link to comment Share on other sites More sharing options...
Rimer Posted March 30, 2006 Share Posted March 30, 2006 Well I am not shure that JS generally allows for grabbing get or post values but you can use php and javascript together. For example <?PHP $id = $_GET['id'];$field = $_GET['field'];?><script type="text/javascript">var wid =<? echo $id; ?>;var wfield =<? echo $field; ?>;</script> It might not be perfect and it is lengthy, but last time I ran the code similiar to it I had no issues and could use my PHP set variables quite easily in my JS. There is probaly a more effective way, but this is the method of choice I use. Link to comment Share on other sites More sharing options...
pulpfiction Posted March 30, 2006 Share Posted March 30, 2006 If you really want to use JavaScript to get the query string values you might wanna take a look at this http://www.tek-tips.com/faqs.cfm?fid=5442 Link to comment Share on other sites More sharing options...
ThePsion5 Posted March 31, 2006 Author Share Posted March 31, 2006 If you really want to use JavaScript to get the query string values you might wanna take a look at this http://www.tek-tips.com/faqs.cfm?fid=5442<{POST_SNAPBACK}> Well, I ended up not using GET values directly in the javascript, but I created two javascript functions that ended up doing what I needed much better anyway. I created one function to open the new window with the specified chrome (or lack thereof) and then created another javascript function executed at the bottom of the page that resized it appropriately. This makes more sense anyway since the size of the page depends on the number of results pulled from a database, so in order to avoid unneeded DB queries I would have had to pass an entire mysql result set through to the new window. And that isn't something I'm going to try and figure out right now. Thanks for the help, guys!-Sean Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now