HighDots Forums  

Re: Global variable not remembering value

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Global variable not remembering value in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David Mark
 
Posts: n/a

Default Re: Global variable not remembering value - 01-21-2008 , 06:26 PM






On Jan 21, 6:08*pm, The Natural Philosopher <a...@b.c> wrote:
Quote:
webmasterATflymagnetic.com wrote:
I would be grateful for some pointers to the code below. I want to
click the button and it toggles the showing of text. The state is
tracked in the variable det. Whilst the function itself works, I have
two questions:

* Why does it not 'stick' with the new value (ie det = true), but keep
reverting to the false value?

I am a javascript novice, but surely you need to tell the function
toggleDetail that det is GLOBAL in scope?
And how would you do that?

Quote:
In C that would be *'external', from memory, in PHP its 'global'..

In C I would declare det as a 'static' variable INSIDE the function..

There's probably a way to do that in Java shit too.
For someone new to JavaScript, you certainly have formed some strong
opinions about it.

Quote:
* Why does it work even more poorly in IE? *The line with
getElementById() in particular seems not to rewrite the HTML.

I THINK I met this befre, SPANS can't have ID's - only DIVS can or
something. Or is it that they cant have inerHTML.
No and no.

Quote:
Now you know why I call it Javashit. Its never the same syntax twice..

Of course, host objects have nothing to do with the language.
JavaScript syntax is very well defined.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.