Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 18th, 2008, 10:19 PM   #1
Logical1
Programmer
 
Logical1's Avatar
 
Join Date: Apr 2008
Posts: 43
Rep Power: 0 Logical1 is on a distinguished road
Question 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>

---------------------------------------------------------------
__________________
^c^
Logical1 is offline   Reply With Quote
Old May 19th, 2008, 7:09 AM   #2
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 416
Rep Power: 3 Wizard1988 is on a distinguished road
Send a message via AIM to Wizard1988
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
Wizard1988 is offline   Reply With Quote
Old May 19th, 2008, 8:42 PM   #3
Logical1
Programmer
 
Logical1's Avatar
 
Join Date: Apr 2008
Posts: 43
Rep Power: 0 Logical1 is on a distinguished road
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.
Logical1 is offline   Reply With Quote
Old May 19th, 2008, 9:08 PM   #4
iEngage
Newbie
 
iEngage's Avatar
 
Join Date: May 2008
Location: teh interwebz
Posts: 22
Rep Power: 0 iEngage is on a distinguished road
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)
  1. <script LANGUAGE="JAVASCRIPT">
  2. <!--
  3. function OSUGGEST(url) {
  4. var url = url +"&url=" + document.location
  5. var NS = (document.layers) ? true : false;
  6. var IE = (document.all) ? true : false;
  7.  
  8. if(NS) {
  9. window.open(url,"","scrollbars=no,menubar=no,personalbar=no,width=500,height=500,screenX=220,screenY=0");
  10. } else if(IE) {
  11. window.open(url,"","scrollbars=no,menubar=no,personalbar=no,width=500,height=500,left=220,top=0");
  12. }
  13.  
  14. }
  15. //-->
  16. </script>
__________________
iEngage
iEngage is offline   Reply With Quote
Old May 19th, 2008, 9:10 PM   #5
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 416
Rep Power: 3 Wizard1988 is on a distinguished road
Send a message via AIM to Wizard1988
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
Wizard1988 is offline   Reply With Quote
Old May 19th, 2008, 9:25 PM   #6
Logical1
Programmer
 
Logical1's Avatar
 
Join Date: Apr 2008
Posts: 43
Rep Power: 0 Logical1 is on a distinguished road
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^
Logical1 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:35 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC