Congratulations to AcaCandy on her 100,000th post!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell driver drivers email error ethernet excel firefox firefox 3 game hard drive internet internet explorer itunes laptop linux malware monitor network networking nvidia outlook outlook 2003 outlook 2007 outlook express partition problem router slow software sound trojan usb video virus vista wifi windows windows vista windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
"Javascript", How to use the passed arguement in the function


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
fazthegreat's Avatar
Member with 84 posts.
 
Join Date: Dec 2005
15-Feb-2006, 05:08 AM #1
"Javascript", How to use the passed arguement in the function
Hi, I'm trying to write a little function that will accept an arguement as follows:

function FloorPlan(plan)

{
FloorPlanWindow= window.open("","FWin1","width=550,height=550,left=100,top=0");
FloorPlanWindow.document.write("<HTML><HEAD><\/HEAD><BODY BGCOLOR='e0d9aa'><center><IMG SRC='plan'><\/center><br><center><a href='javascript:window.close()''>Close Window<\/a><\/center><\/BODY><\/HTML>");

FloorPlanWindow.focus();
}

I'm calling this function from this link:
<a href="javascript:FloorPlan('images/A1_1br-1ba.jpg')">C1</a>

What am i doing wrong coz the passed arguement does not work.How do i use "plan" (passed arguement) in the code to write html to the window.

Please someone help!
Thanks
n7Epsilon's Avatar
Computer Specs
Senior Member with 322 posts.
 
Join Date: Aug 2004
Location: Cairo, Egypt
Experience: Intermediate+ to Advanced
15-Feb-2006, 06:15 AM #2
Smile Here's what works...
Hi,
The mistake you are making is that you are placing the variable "plan" directly inside the quotes, so it is interpreted as a string literal (not as a variable)

Example:
Code:
var Test="fazthegreat";
document.write("Hello 'Test' !");
Will output:
Hello 'Test' !

but this on the other hand:
Code:
var Test="fazthegreat";
document.write("Hello '" + Test + "' !");
will output:
Hello 'fazthegreat' !

ie: If you are going to use a variable inside a string in a Javascript function you must split the string at this variable and add the variable as a separate value (without quotes) within the string then add the rest of the string as another separate value with...

"Hello " + variable + " !" is correct
"Hello variable !" will make javascript think that variable is part of the literal string...

Hope that helps you and use the code tags next time as they really help to differentiate code from the rest of the post
__________________
I should have learnt C# a long time ago! It's a powerful language, and it's much better in .NET 2.0.
Internet Explorer 6 is the worst browser ever, Get FireFox now! | Get Opera!
At the VERY least Get Internet Explorer 7 !
fazthegreat's Avatar
Member with 84 posts.
 
Join Date: Dec 2005
15-Feb-2006, 04:19 PM #3
Great, thanks very much.That was it!
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:48 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.