473,806 Members | 2,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1132

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">
someFunctionTha tIsDefinedInFil eDotJs(paramete r1, parameter2);
</script>
</body>

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript 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("Hel lo, 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
2609
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 system.drawing.dll Additional information: Overflow or underflow in the arithmetic operation.
0
1841
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 stable release and once activated it requested access to the net. Without access it would come up with recognition and 'localhost' connection errors? Can anyone please tell me:
8
1835
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 downloaded Python; It's pretty good isn't it? It's particularly handy being able top run the same bytecode on different platforms.
10
2940
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 routines that upload and process images. I can't get past "square one" with images in C#: This statement:
4
357
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 only one case record that is delivered by a stored procedure. (I have a stored procedure that works so my question is only on loading the DataSet.) The DataSet will only be used for printing form letters and then will be zapped. I would like...
4
1284
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 trips" to the browser or am I accessing one instance. If five round trips occur then I will develop some parsing algorithm to save everything I need in one cookie.
2
4161
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 converted an app to VS2005 and this still worked. In VS2005 I can't do this. I have examined the code for VS2003 and I see that there is a style="Z-INDEX... " in the asp code for the
2
3713
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 string. The vb example outputs "A94A8FE5CCB19BA61C4C0873D391E987982FBBD3" The cs example outputs "5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8" for the string "password" Question: do the 2 applications use different automatic "salts" or "seeds" to...
10
11529
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 script? files=glob.glob('*.py') print files Traceback (most recent call last):
5
1834
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. Since this application has to process and distribute plain text around the network, I am wondering if there are any peformance differences between C++ std::string and C char in run time?
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10624
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10111
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3853
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.