473,408 Members | 2,832 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,408 software developers and data experts.

Global Variable vs Hidden Input TextBoxes

Currently I'm using hidden input textboxes to store session variables
(eg. login_id, first_name, last_name). So when I need to use the
values in a fuction I would do login_id.value, etc.. I'm thinking if
it's better to just set the login_id, etc.. as global variables. I
may have a lot of variables and the session may be long. I'm worried
that I might lose global variables due to memory leaks and other
issues. In my mind if I store it in a hidden textbox the text
actually is stored on the page so it won't just disappear. Any
thoughts? Thanks...
Feb 8 '08 #1
2 4320
SAM
mo*****@yahoo.com a écrit :
Currently I'm using hidden input textboxes to store session variables
(eg. login_id, first_name, last_name). So when I need to use the
values in a fuction I would do login_id.value, etc.. I'm thinking if
it's better to just set the login_id, etc.. as global variables. I
may have a lot of variables and the session may be long. I'm worried
that I might lose global variables due to memory leaks and other
issues. In my mind if I store it in a hidden textbox the text
actually is stored on the page so it won't just disappear. Any
thoughts? Thanks...
Really, JS global variables can disappear ?

Is there a difference between :
- to remember what is coded in the body (hidden values) of the page
- and to remember what is coded in the head (JS global variables)?

Now, if you need these hidden values, yes why not to use them instead to
work with their JS clones.
--
sm
Feb 8 '08 #2
mo*****@yahoo.com said the following on 2/8/2008 4:58 PM:
Currently I'm using hidden input textboxes to store session variables
(eg. login_id, first_name, last_name). So when I need to use the
values in a fuction I would do login_id.value, etc.. I'm thinking if
it's better to just set the login_id, etc.. as global variables. I
may have a lot of variables and the session may be long. I'm worried
that I might lose global variables due to memory leaks and other
issues. In my mind if I store it in a hidden textbox the text
actually is stored on the page so it won't just disappear. Any
thoughts? Thanks...
Namespace them.

var myVariables = {}
myVariables.login_id = "something"
myVariables.first_name = "First name"

And so on. Then, you only have one chance for a name clash and you are
only creating one global variable name.

I think you are being overly-paranoid about memory leaks losing global
variables though.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 9 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Larry L | last post by:
I have a Module that declares several arrays as public, some string, some integers. I then have 2 forms. Form A is the main form, that loads on start-up, and has a command button to open Form B. On...
6
by: BigDadyWeaver | last post by:
I am using the following code in asp to define a unique and unpredictable record ID in Access. <% 'GENERATE UNIQUE ID Function genguid() Dim Guid guid =...
3
by: Geoff Winsor | last post by:
Hi, I am experiencing a problem with recalling a session variable which stores whether a person is logged in to a "members only" section of a website. This area of the site has been working...
9
by: lkrubner | last post by:
I've got a function, you can see it below, that is being called onmouseup in the textarea on my main form. The idea is to find a selection if possible and store that text in a global variable. I...
6
by: Soha | last post by:
I'm a beginner in using javascript and i need a reply so urgent; i have a problem in using javascript with asp the problem is that i want to define a global variable and then change the value of it...
6
by: Bob Darlington | last post by:
I have an Access XP app running over TS with Windows 2000 Server. There are 5 sites (each with 3 or 4 users) accessing the data file, and each has its own front end mde on the server. The mde's...
9
by: ruca | last post by:
How can I declare a global variable in my .js file, that I can preserve her value each time I need to call any function of .JS file in my ASP.NET application? Example: var aux=null; function...
8
by: JJ | last post by:
Whats the best way to pass a variable from a popup to the current page (without a postback on the current page). I have a form on 'page1' with various text input boxes. One box contains an image...
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.