![]() |
Passing a variable to a pop up window
Hello guys
I am using a simple script to open a little window for userfirendly print version of some pages. I need to pass an id number to it. Altough I am using javascript for this I know nothing about this language. Any idea as how to go about it? I think you in advance. Here is the code for the link and the java script for pop up: I need to pass Id=123 to this link >>> <a href="javascript:OSUGGEST('printfriendly.php)";>Print</a>--------------------------------------------------- <script LANGUAGE="JAVASCRIPT"> <!-- function OSUGGEST(url) { var url = url +"?url=" + document.location var NS = (document.layers) ? true : false; var IE = (document.all) ? true : false; if(NS) { window.open(url,"","scrollbars=no,menubar=no,personalbar=no,width=500,height=500,screenX=220,screenY=0"); } else if(IE) { window.open(url,"","scrollbars=no,menubar=no,personalbar=no,width=500,height=500,left=220,top=0"); } } //--> </script> --------------------------------------------------------------- |
Re: Passing a variable to a pop up window
Couldn't you just pass it as a get variable?
:
<a href="javascript:OSUGGEST('printfriendly.php?id=123')";>Print</a> |
Re: Passing a variable to a pop up window
Thank you for your answer.
I had tried that but it does not work becasue somehow URL gets added to the end of it! If Id was 200 I get: 200?url=http://www.---.com/----print.php The red part gets added by itself to the end of number!!! With my limited understanding of JS I think function OSUGGEST(url) is expecting t get one variable (URL) and adding the number to it just messes it up. But my knowledge in JS is not enough to fix the script. Any suggestions is appreciated? Is it possible to pass 2 vraiable to a JS function? |
Re: Passing a variable to a pop up window
change line number 4 to read like this. notice the ampersand instead of the question mark. Then pass it as a GET variable as suggested by Wizard1988. it will still add all that stuff to the end. but instead of messing up your variable it will create a different GET variable as well. Which should make your ID work properly
:
|
Re: Passing a variable to a pop up window
There is a way to get around that. Change "url +"?url=" + document.location" to "url +"&url=" + document.location" Normally GET variables are separated by '&' symbols (notice the URL when you are replying to this post)
Hopefully that helps I see that iEngage beat me with the reply... |
1000,000 thanks
One million thanks guys. Solved the problem. I guess I have to eventually sit and learn the darned langauge (I usually work in PHP).
Hope to return the favor some day. Logical1 |
| All times are GMT -5. The time now is 4:16 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC