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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass variables on Web 2

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
0
0
US
How do you pass a value of a variable from one page to another in ASP or VBScript?? Rob
Just my $.02.
 
Sending Page:

<a href=&quot;targetpage.asp?item1=value1,item2=value2&quot;></a>

Item being the name of your variable and of course value being the value for that item.

Catch on receiving page:

Dim var1, var2

var1 = Request.Querystring(&quot;item1&quot;)
var2 = Request.Querystring(&quot;item2&quot;)

Of course you could also post these values through a form as well.

It all depends on just exactly how you want to do it.

Dave
 
Hi Rob

Is the variable from a form?

If it is not, you can simply set a session variable to carry values from one page to another (although I believe cookies must be enabled at the client side).

Use

<%
Session (&quot;session_variable_name&quot;) = 20
%>

which will assign a value of 20 to the variable &quot;session_variable_name&quot;

Then you can call the variable in any subsequent page by using:

<% Session (&quot;session_variable_name&quot;) %>

IF, HOWEVER,

the variable is part of a form you call the next page from the submit button (METHOD=&quot;post&quot; ACTION=&quot;nextpagename.asp&quot;)

You can reference variables collected in the form (including hidden variables) by using:

<% Request.Form (&quot;form_field_name&quot;) %>

Hope this helps (I remember I had to spend ages working out how to do this, so hopefully this is of use to you!)

Pete
 
I posted the above at the same time as Dave -

I didn't think of Request.Querystring - that's neater than using session vars!

Cheers Dave!

Pete
 
Thanks to ya both. You are right Pete, I'm pulling my hair out. Rob
Just my $.02.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top