JavaScript Variable Question...

I feel ashamed of asking this...

Page 1 of 1

2 Replies - 1406 Views - Last Post: 17 May 2002 - 06:40 AM

#1 Fygar  Icon User is offline

  • I liek milk!!1
  • member icon

Reputation: 6
  • View blog
  • Posts: 4,361
  • Joined: 28-March 02

JavaScript Variable Question...

Posted 16 May 2002 - 09:10 AM

*Disclaimer*
I JUST started learning Javascript, So the following may be the dumbest question on earth, but I can't figure it out...
************

OK, I want to know if I can change data in a global variable after I have set the variable... In a function, I tried to re-assign data to a glabal variable, but it won't write to it... I was just wonder what the trick was. thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: JavaScript Variable Question...

#2 Sem  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 199
  • Joined: 10-February 02

Re: JavaScript Variable Question...

Posted 16 May 2002 - 10:51 PM

Could you post the code?

Just taking a stab here, but did you forget to omit the 'var' portion in your function when changing the variable:

ex1.
function yadda(){
var whatever = 1;
}

ex2.
function yadda(){
whatever = 1;
}

Ex1 sets a variable named whatever in the function itself, while ex2 augments a global variable. I think.

Did this help?

Sem

(Edited by Sem at 11:52 pm on May 16, 2002)

Was This Post Helpful? 0
  • +
  • -

#3 Fygar  Icon User is offline

  • I liek milk!!1
  • member icon

Reputation: 6
  • View blog
  • Posts: 4,361
  • Joined: 28-March 02

Re: JavaScript Variable Question...

Posted 17 May 2002 - 06:40 AM

Thanks, Sem, that did the trick. Java is veeerrrry picky about a lot of stuff... it is no VBScript... lol, Thanks again.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1