Simple Javascript Help

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Simple Javascript Help

Post by spacebiscuit »

Hi guys,

I code in PHP but can't figure out a simple bit of javascript! I want to use variables for a popup script:

Code: Select all

<script language="JavaScript">
function popup(pagename){
window.open(pagename.'.php','popjack','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes,width=427,height=400');}
</script>
The HTMl to call the javascript

Code: Select all

<a href="JavaScript: popup(pagename)">terms and conditions</a>
I'm obviusly doing what I would if I was coding in PHP - what am I missing?

Thanks,

Rob.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Simple Javascript Help

Post by McInfo »

In JavaScript, plus (+) is the concatenation operator.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Simple Javascript Help

Post by spacebiscuit »

Ok thanks - I have changed that.

Now I am getting an error which says the parameters is undefined:

for example:

Code: Select all

<a href="JavaScript: popup(pagename)">
The error says that 'pagename' is undefinted.

Thanks in advance,

Rob.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Simple Javascript Help

Post by McInfo »

Replace pagename with something else, like a variable that is defined or a string.

Code: Select all

popup('index');
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Simple Javascript Help

Post by spacebiscuit »

Perfect thans, I just had to add the quotations to cast the paramater as a string.

Your help is appreciated.

Rob.
Post Reply