![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Apr 2008
Posts: 47
Rep Power: 0
![]() |
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> ---------------------------------------------------------------
__________________
^c^ |
|
|
|
|
|
#2 |
|
Professional Programmer
|
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>
__________________
JG-Webdesign |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Apr 2008
Posts: 47
Rep Power: 0
![]() |
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?
__________________
^c^ Last edited by Logical1; May 19th, 2008 at 8:56 PM. |
|
|
|
|
|
#4 |
|
Newbie
Join Date: May 2008
Location: teh interwebz
Posts: 22
Rep Power: 0
![]() |
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
javascript Syntax (Toggle Plain Text)
__________________
iEngage |
|
|
|
|
|
#5 |
|
Professional Programmer
|
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...
__________________
JG-Webdesign |
|
|
|
|
|
#6 |
|
Programmer
Join Date: Apr 2008
Posts: 47
Rep Power: 0
![]() |
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
__________________
^c^ |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing variable from one form to another | randum77 | Visual Basic .NET | 7 | Apr 17th, 2007 10:38 AM |
| Passing a string to a variable | fresher | Java | 5 | Jan 11th, 2007 6:31 AM |
| Arranging Views of Project Explorer, Property window and Form Layout | java_roshan | Visual Basic | 6 | Sep 30th, 2005 2:55 PM |
| New Window | Chris Weimer | HTML / XHTML / CSS | 3 | Sep 20th, 2005 9:18 AM |
| variable problem | robert_sun | C | 1 | Apr 12th, 2005 2:10 PM |