Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable transfer question

Status
Not open for further replies.

rtnMichael

Programmer
Aug 5, 2002
152
US
Hey,
I have info I need to transfer throughout other pages, not just the next page, but the one after that and so on. How would I do that?

Thanks
M
 
the use of session variables give you this freedom
example: if you want to have a cost of $5 for a shipping amount and you want to use this for items on several different pages after the user selects one for purchasing all you would need to do is add this variable holding the amoutn it it, so
syntax session variable
session("shipping") = "5"

this simple line now has saved the value 5 for use in any page at anytime for the session the user has open.

the catch...if you want this variable to be a constant in a sense then you will use a application variable which should be declared in the global.asa most of the time.
not much different in the syntax
application("shipping") = "5"
in the Application_OnStart sub

then call both like any other variable
varTotal = itmPrice + session("shipping")

I like for ease of reading code to declare variables in pages and then have them hold the session variables value, if the list of variables is not too exstensive. it makes debugging much easier

hope that helps out A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
yeah, I believe that's what I needed to know

Thanks
M
 
ok, is it done like this:
session("program") = request.form("program_name")

or like this:
set program = request.form("program_name")
session("program") = program

I tried the first one, and it didn't work

 
provided that the form value is present and you have submited the form then this practice example will work
save two files..first= test.htm second= testVar.asp
test.htm
<html>
<body>
<form name=&quot;frm&quot; method=&quot;post&quot; action=&quot;testVar.asp&quot;>
<input type=&quot;text&quot; name=&quot;program_name&quot;>
<input type=&quot;submit&quot; value=&quot;submit&quot;>
</form>
</body>
</html>

testVar.asp
<%
session(&quot;program&quot;) = request.form(&quot;program_name&quot;)
response.write session(&quot;program&quot;)
%>

try this and let us know if it worked properly A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
I got it, I wrote:
session(&quot;name&quot;) = request.form(&quot;name&quot;)
and
<%Response.write &quot;&quot; & session(&quot;name&quot;) & &quot;&quot;%>

and it worked

Thanks for the help
M
 
OK
but the &quot;&quot;& &&quot;&quot; don't need to be there unless you wanted quotes around it. that's probably what you meant by that though. at that point I would use chr(34) though. makes life easier when you're looking over a lot of pages of code with a million quotes.

A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
gotcha, I didn't even notice I could do it without the &quot; &quot;

Thanks for the looking out
M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top