/    Sign up×
Community /Pin to ProfileBookmark

Value from another JS file

Hi,

How can I capture value result from another js file to calculate in another js file? I have this calculated value in one js file to use in another js but I dont know how to.. ?

Thnks…for ur guidance.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@emoritzOct 08.2006 — example please?
Copy linkTweet thisAlerts:
@jvanamaliOct 08.2006 — here is a sample code

calling.html[CODE]
<HTML>
<Head>
<script type="text/javascript" src="test2.js"></script>
<script type="text/javascript" src="test1.js"></script>
</Head>
<Body>
Test Page
</Body>[/CODE]


test1.js
[CODE]var a = 10;
var b = 40;
var c = fnAdd(a,b);
alert (c);[/CODE]

test2.js
[CODE]function fnAdd(a,b){
var c=a+b;
return c;
}[/CODE]
Copy linkTweet thisAlerts:
@emoritzOct 09.2006 — that should work, although it would be wiser to use different variable names for global and local variables. they could get mixed up.
Copy linkTweet thisAlerts:
@FutureZoneauthorOct 10.2006 — Hi All,

Thank you so much? It's great!

?
×

Success!

Help @FutureZone spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...