473,396 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

a newby question

hi, i´m starting to use javascript in my web, and i have a quite simple
question:
how can i call to a function which is in another .js file, giving it some
parameters and receiving some data??
i only knew
<script type="text/javascript" src="file.js"></script>

Thanks
Jul 23 '05 #1
4 1114

Ricardo Garcia wrote:
hi, i´m starting to use javascript in my web, and i have a quite simple
question:
how can i call to a function which is in another .js file, giving it some
parameters and receiving some data??
i only knew
<script type="text/javascript" src="file.js"></script>


exactly the same way as if function were in file you're calling function
from.. as long as JavaScript knows where to find the .js file it'll
find the function.. goog luck.. Frances

Jul 23 '05 #2
Ricardo Garcia wrote:
hi, i´m starting to use javascript in my web, and i have a quite simple
question:
how can i call to a function which is in another .js file, giving it some
parameters and receiving some data??
i only knew
<script type="text/javascript" src="file.js"></script>

Thanks


<head>
<title>Test</title>
<script type="text/javascript" src="file.js"></script>
</head>
<body>
<script type="text/javascript">
someFunctionThatIsDefinedInFileDotJs(parameter1, parameter2);
</script>
</body>

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #3
Lee
Ricardo Garcia said:

hi, i´m starting to use javascript in my web, and i have a quite simple
question:
how can i call to a function which is in another .js file, giving it some
parameters and receiving some data??
i only knew
<script type="text/javascript" src="file.js"></script>


If the function is in file.js, you include the line above, and
then, in a separate <script> tag, invoke the function with your
parameters. So if the function is myFunction(str), you could use:

<script type="text/javascript" src="file.js"></script>
<script type="text/javascript">
myFunction("Hello, world!");
</script>

Jul 23 '05 #4
Ricardo Garcia wrote:
hi, i´m starting to use javascript in my web, and i have a quite simple
question:
how can i call to a function which is in another .js file, giving it some
parameters and receiving some data??
i only knew
<script type="text/javascript" src="file.js"></script>

Yes.
As long as the JavaScript is in the same web-page as the one that calls
it, it doesn't matter where in the page it is or how it gets there (in
other words, it can be written in the page or loaded from one or more
files). Many people put different "snippets" of JavaScript in different
files - I do myself - and then load them into pages where that snippet
is to be used.
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Damien | last post by:
I have just built a simple stopwatch application, but when i f5 to get things goings i get this message, An unhandled exception of type 'System.ArithmeticException' occurred in...
0
by: Pete | last post by:
Hi All, A total Newby with, possibly, a daft question? However, until I can get a reasonable explanation I am disinclined towards going further. Here goes: I recently downloaded the latest...
8
by: Ask | last post by:
G'day All, Just thought I'd drop in and say hi. I'm new to Python, but old to software development. Python is one of the languages used in my new job, so I've just bought a book, read it, and...
10
by: Fred Nelson | last post by:
Hi: I have programmed in VB.NET for about a year and I'm in the process of learing C#. I'm really stuck on this question - and I know it's a "newby" question: In VB.NET I have several...
4
by: Fred Nelson | last post by:
I have an applicatioin that I'm writing that uses a "case" file that contains over 350 columns and more may be added in the future. I would like to create a dataset with all the column names and...
4
by: Fred Nelson | last post by:
Hi: I'm developing a web application that needs to have five values, each retrieved from cookies on many pages. If I have five "Request.Cookies" commands together does this cause five "round...
2
by: Fred Nelson | last post by:
Hi: I'm working on a VS2005 web application and I have what is probabably a "newby" question. In VS2003 I could drag a textbox/button/etc on to a form and position it with the mouse. I...
2
by: johnnyG | last post by:
Greetings, I'm studying for the 70-330 Exam using the MS Press book by Tony Northrup and there are 2 side-by-side examples of using the SHA1CryptoServiceProvider to create a hash value from a...
10
by: Charles Russell | last post by:
Why does this work from the python prompt, but fail from a script? How does one make it work from a script? #! /usr/bin/python import glob # following line works from python prompt; why not in...
5
by: alexrixhardson | last post by:
Hi guys, I am a newby in the C/C++ world, and I am beginning to work on a rather simple TCP/IP proxy application which must be able to handle large volume of data as quickly as possible. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.