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

Passing Variables

Status
Not open for further replies.

mot98

MIS
Jan 25, 2002
647
CA
Hi all,

I am working on some ASP pages. I am on my 3rd page, and am looking to use variables that I set in my 1st and 2nd pages.

I can get the variable from the 2nd page no probs with a
*=Response.Form (*)

But I don't think I can use the same tool to get the variable from the 1st page form.

How do I get that variable?

Any help would be greatly appreciated.

Thanks, mot98..[peace]

"Where's the beer?"
 
Several options:

1. Use cookies
2. Use session variables
3. Use hidden form values and submit them to the 3rd page (from the second page)

You can look up the above in these forums. I would probably sway towards number 3 as there are less issues regarding heavy usage etc, but it depends on your particular circumstances.

I haven't got time to expand further right now but if you need more help just ask and I or someone else will provide more info.
 
Can anyone explain how to pass hidden variables??

Thanks,
mot98..[peace]

"Where's the beer?"
 
On your second page, request all the values from the first page:

<%
dim var
var = Request.form(&quot;Value_From_Form_1&quot;)
%>

In the form on your second page, include hidden form fields:

<form>
<input type=hidden name=&quot;Var_From_Form_1&quot; value=&quot;<%=var%>&quot;>
...Rest of form stuff here...
</form>


Then on your third page, just request the values the same way as all your other values:

<%
dim var
var = Request.form(&quot;Var_From_Form_1&quot;)
%>
 
second page
<input type=&quot;hidden&quot; value=(Request.Form('formValue') name=&quot;hidden1&quot;>

then call it in the third page like this
Request.Form('hidden1')

the syntax may be wrong in the value. might need quotes around it but that should do it.
provide tools to let people become their best.
 
Sorry, don't forget the <% %>
value=<%Request.Form('hidden1')%> provide tools to let people become their best.
 
When I do this I am getting a type missmatch on the value =&quot;<%var%>&quot;

Is that a new variable that I now create??

Here is my code from the second page

<%
Dim ItemVendor
parmvendor = Request.Form (&quot;VendorChoice&quot;)
Dim oRSb
Set oRSb=Server.CreateObject(&quot;ADODB.Recordset&quot;)
sqltext= &quot;SELECT ItemType FROM Items WHERE ItemVendor= &quot; & parmvendor & &quot;;&quot;
oRSb.Open sqltext , &quot;DSN=Clothier&quot;
oRSb.MoveFirst
%>

<center>
<form><input type=hidden name=&quot;VendorId&quot; value=&quot;<%parmvendor%>&quot;>
<Method=&quot;post&quot; Action=&quot;results.asp&quot;>
<P><Select Name=&quot;ItemChoice&quot; Size=&quot;1&quot;>

What am I doing wrong here?? The form on the first page is called &quot;VendorChoice&quot; and I am trying to pass the value of &quot;VendorId&quot;

Thanks mot98..[peace]

&quot;Where's the beer?&quot;
 
In this line, you are forgetting to write the variable:
<input type=hidden name=&quot;VendorId&quot; value=&quot;<%parmvendor%>&quot;>

Do this instead:
<input type=hidden name=&quot;VendorId&quot; value=&quot;<%=parmvendor%>&quot;>

Then on your third page, use
Request.form(&quot;VendorId&quot;)


 
O.k....this works...

But it overwrites the form value of the second page.

I have a form on page 1 and a form on page 2. I need to pass the variable from form 1 to page 3. I also need to pass the variable for form 2 on page 2 to page 3.

Any idea's??

Thanks.
mot98..[peace]

&quot;Where's the beer?&quot;
 
I new the syntax was wrong for that. Never did it that way.
It sounds like you should be creating session variables in your case then.
like
<%
Session(&quot;name&quot;)=&quot;&quot;
%>

provide tools to let people become their best.
 
Make a new variable for the value from page 1 and a new hidden and request these on the third page.

Page 2
<%
Dim ItemVendor, Form1_Value
parmvendor = Request.Form (&quot;VendorChoice&quot;)
Form1_Value = Request.form(&quot;Name_of_Form_Element_On_Page1&quot;)

Dim oRSb
Set oRSb=Server.CreateObject(&quot;ADODB.Recordset&quot;)
sqltext= &quot;SELECT ItemType FROM Items WHERE ItemVendor= &quot; & parmvendor & &quot;;&quot;
oRSb.Open sqltext , &quot;DSN=Clothier&quot;
oRSb.MoveFirst
%>

<center>
<form><input type=hidden name=&quot;VendorId&quot; value=&quot;<%=parmvendor%>&quot;>
<input type=&quot;hidden&quot; name=&quot;hdnValue&quot; value=&quot;<%=Form1_Value%>&quot;>
<Method=&quot;post&quot; Action=&quot;results.asp&quot;>
<P><Select Name=&quot;ItemChoice&quot; Size=&quot;1&quot;>



Then on page 3 request the new hidden. I would change the variable names and name of the hidden to be something more descriptive to you and your application, however.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top