473,320 Members | 1,946 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,320 software developers and data experts.

javascript global variables

8
i created a javascript function that would calculate the total values of an array . (just addition) - and it did work and display correctly in that function.

i initialized the variable where i saved the total at the top of the javascript page (out side the function and initialized it to 0)

[HTML]total += parseInt(price[sha]);[/HTML]

but when i created another function in the intension of using that value ( the total which i calculated in the above function), i am getting a zero instead the value which was calculated .. ( i got the zero bcoz i initialized that variable to 0) .. even whe i removed the 0, it didnt work ...

how can i access the value of the total variable which i calculated above .. ?

cant we have global or universal variables in javascripts ?

is there any other technique where i can access that variable ?

plzzz provide me with a code ....

plzz help
Jun 12 '08 #1
2 1478
gits
5,390 Expert Mod 4TB
of course you have private and global variables ... show the entire code that is not working ... variable scope is such a basic issue that a basic tutorial like this is a good starting point ...

kind regards
Jun 12 '08 #2
rnd me
427 Expert 256MB
from anywhere, window.myVariable will create/refer to a global named myVariable.
Jun 14 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Andy Fish | last post by:
Hi, can anybody put forward a sensible argument javascript's behaviour of creating a new global variable whenever I assign to a previously undeclared variable. I can't beleive this is just for...
8
by: Sergio Otoya | last post by:
Hi all, I need to add an input hidden field to an existing form (post). I have tried a couple things like adding the '<INPUT type=hidden name=idSelectedURL value=http://server/documents>' to...
23
by: Matt Silberstein | last post by:
Are there any good qualities libraries out there, free or for "reasonable" cost? -- Matt Silberstein Do something today about the Darfur Genocide http://www.beawitness.org
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
3
by: sunbeam | last post by:
Short Description of the Project: we developed a e-learning system for our students. each student has a unique username/password to view the modules he/she should view and nothing more. since we...
13
by: Walton | last post by:
I'm wondering if anyone knows or knows where to find a collection of javascript "brain teasers" for lack of a better description. Companies use these types of tests for programmers all the time...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
15
by: Sampat | last post by:
Hi, I wanted to know the performance of calling a function pointer v/s a normal function call in javascript in a scenario where there are multiple calls in the js to the same function. Please...
20
by: shapper | last post by:
Hello, How to create a namespace in Javascript containing two methods? And how to access those methods? Thanks, Miguel
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.