By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

variable in function for a new window

P: n/a
hello,

i have got a javascript that opens a new window.
when i call the javascript function i want to ad a variable.
what you see on the pop up depends on the variable.

but the variable in the functions does not work.
on the pop up page it has the value:
$nummer = $_GET['formulier']
echo 'nummer: ' . $nummer
gives: nummer: nummer

i have tried changing the quotes in the function but it does not work
----------------------- source function call ------------
<a href='#' onClick="javascript:popupOpenen(1)">info</a>
--------------------------------------------------------

-------------------- source javascript function ---------------
<script type="text/javascript">
function popupOpenen(nummer){
win=window.open("popup.php?formulier=nummer","","t op=275,left=5,
width=900px, height=380px, scrollbars=yes");
}
</script>
-------------------------------------------------------------

thanks
Oct 13 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Lee
nescio said:

hello,

i have got a javascript that opens a new window.
when i call the javascript function i want to ad a variable.
what you see on the pop up depends on the variable.

but the variable in the functions does not work.
on the pop up page it has the value:
$nummer = $_GET['formulier']
echo 'nummer: ' . $nummer
gives: nummer: nummer

i have tried changing the quotes in the function but it does not work
How did you try changing them? What does "it does not work" mean?
The personal pronoun is capitalized when writing English, particularly
in a newsgroup where lower-case "i" is a common variable name

-------------------- source javascript function ---------------
<script type="text/javascript">
function popupOpenen(nummer){
win=window.open("popup.php?formulier=nummer","","t op=275,left=5,
width=900px, height=380px, scrollbars=yes");
}
</script>


When you include the name of a variable inside quotes, all you are
passing is the name of the variable.
The width and height should not specify units.
There is no need to store the window object in a variable that you
immediately discard:

function popupOpenen(nummer) {
window.open("popup.php?formulier="+nummer,
"",
"top=275,left=5,width=900,height=380,scrollbars=ye s");
}

Oct 13 '05 #2

P: n/a
When you include the name of a variable inside quotes, all you are
passing is the name of the variable.
The width and height should not specify units.
There is no need to store the window object in a variable that you
immediately discard:

function popupOpenen(nummer) {
window.open("popup.php?formulier="+nummer,
"",
"top=275,left=5,width=900,height=380,scrollbars=ye s");
}


it works now, thanks
Oct 13 '05 #3

P: n/a
Hi all,

Can someone tell me where I'm going wrong?

I have created a function to open a new window on a form submit, The
function opens the new window ok but the window height parameter I've tried
passing to the function just won't work!

Ideally I want to pass the width and height attributes, but being new to JS
I thought I'd make it real simple first...

Code follows

**Form tag
<form action="Processor.php" method="post" target="NewWin" onSubmit="return
!PopForm(875);">

**Function code
function PopForm(h)
{
NewWin = window.open('','NewWin','width=400,height=+h');
NewWin.focus();
}

Any help kindly appreciated

Tobierre
Oct 13 '05 #4

P: n/a
Tobierre wrote on 13 okt 2005 in comp.lang.javascript:
NewWin = window.open('','NewWin','width=400,height=+h');


NewWin = window.open('','NewWin','width=400,height='+h);

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 13 '05 #5

P: n/a
Hi thanks for the code snip..

but could you please explain why the quote goes before the +h so that I know
for future reference?

What happens if I then want to add the width as an argument? I can't do
width='+w so a little explanation would be very much appreciated

Regards

Tobierre
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.242...
Tobierre wrote on 13 okt 2005 in comp.lang.javascript:
NewWin = window.open('','NewWin','width=400,height=+h');


NewWin = window.open('','NewWin','width=400,height='+h);

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 14 '05 #6

P: n/a
Tobierre wrote:
Hi thanks for the code snip..
Don't top-post to this newsgroup.

but could you please explain why the quote goes before the +h so that I know
for future reference?
If the 'h' is inside the quotes, it is treated as a literal and you get
an 'h' character. If it is outside the quotes, it is treated as a variable.

What happens if I then want to add the width as an argument? I can't do
width='+w so a little explanation would be very much appreciated

function PopForm(w, h)
{
NewWin = window.open('','NewWin','width=' + w + '400,height=' + h);
...

Here '+' means concatenate.

[...]
--
Rob
Oct 14 '05 #7

P: n/a
Hi Rob,

Thanks for putting me straight with that great explanation.

P.s I did not mean to top post! purely accidental, but thanks for the
reminder

Tobierre

"RobG" <rg***@iinet.net.au> wrote in message
news:yi*****************@news.optus.net.au...
Tobierre wrote:
Hi thanks for the code snip..


Don't top-post to this newsgroup.

but could you please explain why the quote goes before the +h so that I
know for future reference?


If the 'h' is inside the quotes, it is treated as a literal and you get an
'h' character. If it is outside the quotes, it is treated as a variable.

What happens if I then want to add the width as an argument? I can't do
width='+w so a little explanation would be very much appreciated

function PopForm(w, h)
{
NewWin = window.open('','NewWin','width=' + w + '400,height=' + h);
...

Here '+' means concatenate.

[...]
--
Rob

Oct 14 '05 #8

P: n/a
Tobierre wrote on 14 okt 2005 in comp.lang.javascript:
Thanks for putting me straight with that great explanation.

P.s I did not mean to top post! purely accidental, but thanks for the
reminder


So, what where you doing now?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 14 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.