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

Variables

I have a number of form fields that I wish to temporarily record into
variables and pass to a small number of subsequent pages.

Is the best way to save each one to a session variable when I submit the
form and then to clear the variables when I no longer need them?

Also, if this is the best method, what is the code for saving a form field
to a session variable when the form has not yet been submitted. For
example, when I submit Form1, I want the contents of Field1 to be entered
into SessionVariable1 and then the form to be submitted as normal.
Jul 19 '05 #1
7 1412

I don't really get what you're trying to do here exactly, but are you trying
to "save" certain form values and automatically re-use those in several
forms?

"Keith" <@.> wrote in message news:#j*************@tk2msftngp13.phx.gbl...
I have a number of form fields that I wish to temporarily record into
variables and pass to a small number of subsequent pages.

Is the best way to save each one to a session variable when I submit the
form and then to clear the variables when I no longer need them?

Also, if this is the best method, what is the code for saving a form field
to a session variable when the form has not yet been submitted. For
example, when I submit Form1, I want the contents of Field1 to be entered
into SessionVariable1 and then the form to be submitted as normal.

Jul 19 '05 #2
"Keith" <@.> wrote in message news:%2***************@tk2msftngp13.phx.gbl...
I have a number of form fields that I wish to temporarily record into
variables and pass to a small number of subsequent pages.

Is the best way to save each one to a session variable when I submit the
form and then to clear the variables when I no longer need them?

Also, if this is the best method, what is the code for saving a form field
to a session variable when the form has not yet been submitted. For
example, when I submit Form1, I want the contents of Field1 to be entered
into SessionVariable1 and then the form to be submitted as normal.


Session variables occur server side, thus, you MUST submit the form before
they can be put into session variables. The page that the form gets
submitted to (the action attribute of the form) could put the values into
session variables. Assuming your form has method post, and you have inputs
named "foo" and "bar", your form handler could do something like this:

<%
Session("foo") = Request.Form("foo")
Session("bar") = Request.Form("bar")

Response.Write "<div>Session(""foo"") = "
Response.Write Session("foo")
Response.Write "</div>"
Response.Write "<div>Session(""bar"") = "
Response.Write Session("bar")
Response.Write "</div>"
%>

Regards,
Peter Foti
Jul 19 '05 #3
You submit the form as normal, but on the page it is submitted to is where
you add the values to the Session Variables.

Coding "off the cuff" is dangerous for me but it would look something like
this on the second page. If the Session Variable is called "Person" and the
form field is called "MyName" then:

Session("Person") = Request.Form("MyName")

From here it will stay in the Session Variable as long as the Session is
alive or until you change it to some other value. It will be available to
any page at anytime after that as long as it is the same Session.

To retreive it into a variable:
strMyString = Session("Person")
To display it in the browser:
Resonse.write Session("Person")
--

Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com
"Keith" <@.> wrote in message news:#j*************@tk2msftngp13.phx.gbl...
I have a number of form fields that I wish to temporarily record into
variables and pass to a small number of subsequent pages.

Is the best way to save each one to a session variable when I submit the
form and then to clear the variables when I no longer need them?

Also, if this is the best method, what is the code for saving a form field
to a session variable when the form has not yet been submitted. For
example, when I submit Form1, I want the contents of Field1 to be entered
into SessionVariable1 and then the form to be submitted as normal.

Jul 19 '05 #4
Yes. I am trying to save the values of several form fields and reuse them,
but wanted to know if there was a way of saving them without submitting the
form. I know I can use session variables, but wondered if other types of
variables existed that may suite better etc.

"J. Baute" <WU**********@spammotel.com> wrote in message
news:40*********************@news.skynet.be...

I don't really get what you're trying to do here exactly, but are you trying to "save" certain form values and automatically re-use those in several
forms?

"Keith" <@.> wrote in message news:#j*************@tk2msftngp13.phx.gbl...
I have a number of form fields that I wish to temporarily record into
variables and pass to a small number of subsequent pages.

Is the best way to save each one to a session variable when I submit the
form and then to clear the variables when I no longer need them?

Also, if this is the best method, what is the code for saving a form field to a session variable when the form has not yet been submitted. For
example, when I submit Form1, I want the contents of Field1 to be entered into SessionVariable1 and then the form to be submitted as normal.


Jul 19 '05 #5

"Keith" <@.> wrote in message news:#c**************@tk2msftngp13.phx.gbl...
Yes. I am trying to save the values of several form fields and reuse them, but wanted to know if there was a way of saving them without submitting the form. I know I can use session variables, but wondered if other types of
variables existed that may suite better etc.


Storing the values in cookies are anothother possibility, but frankly I'd go
for the Session object anyway.

You could also set cookies from ASP when the form is posted, but in that
case you can just as well use the session object, which also uses a cookie
but the data can't be retrieved from it clientside. Or you can set cookies
straight from JavaScript before your form is posted.


Jul 19 '05 #6
Thank you

I think I will stick with session variables like I had thought in the first
place then.

I will just make a point of clearing them when I have finished with them so
there are not unnecessary ones during a session.

Do these variables have any impact on performance and resources does anyone
know?
"J. Baute" <WU**********@spammotel.com> wrote in message
news:40*********************@news.skynet.be...

"Keith" <@.> wrote in message news:#c**************@tk2msftngp13.phx.gbl...
Yes. I am trying to save the values of several form fields and reuse

them,
but wanted to know if there was a way of saving them without submitting

the
form. I know I can use session variables, but wondered if other types of variables existed that may suite better etc.


Storing the values in cookies are anothother possibility, but frankly I'd

go for the Session object anyway.

You could also set cookies from ASP when the form is posted, but in that
case you can just as well use the session object, which also uses a cookie
but the data can't be retrieved from it clientside. Or you can set cookies
straight from JavaScript before your form is posted.

Jul 19 '05 #7

"Keith" <@.> wrote in message news:OV**************@TK2MSFTNGP09.phx.gbl...
Thank you

I think I will stick with session variables like I had thought in the first place then.

I will just make a point of clearing them when I have finished with them so there are not unnecessary ones during a session.

Do these variables have any impact on performance and resources does anyone know?


Since session variables are stored in memory, storing a lot of them for
every users session could lead to performance issues concerning your memory
use.
Remember that your session doesn't end when a user quits his browser app.
That session will still be in memory until it times out serverside, so it's
definatly a good idea to free those form variables if you don't need them
anymore to free up some memory.

Jul 19 '05 #8

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

Similar topics

2
by: Hal Vaughan | last post by:
First, I am aware of both SwingUtilities.invokeLater(), and of using Thread to create a new thread.  These are part of the problem. I want to have something running in the background, while the...
4
by: Torsten Bronger | last post by:
Hallöchen! I have a file that looks a little bit like a C header file with a long list of variables (actually constants) definitions, e.g. VI_ATTR_TIMO = 0x54378 .... Actually I need this...
1
by: mark4asp | last post by:
What are the best methods for using global constants and variables? I've noticed that many people put all global constants in a file and include that file on every page. This is the best way of...
5
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
7
by: Michael | last post by:
Hi newsgroup, as the subject indicates I am looking for an advice using global variables. I am not if this problem is more about style then C. If its wrong in thi group, sorry. So I have a...
9
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
7
by: misha | last post by:
Hello. I was wandering if someone could explain to me (or point to some manual) the process of mapping the addresses of host variables by DB2. Especially I would like to know when DB2 decides to...
5
by: Sandman | last post by:
I dont think I understand them. I've read the section on scope in the manual inside out. I'm running PHP 5.2.0 Here is the code I'm working on: //include_me.php <?php $MYVAR = array(); global...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
4
by: icarus | last post by:
global_vars.py has the global variables set_var.py changes one of the values on the global variables (don't close it or terminate) get_var.py retrieves the recently value changed (triggered right...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.