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!

rules for passing variables

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
0
0
US
I am working on an .asp project with several other programmers. I am somewhat familiar with .asp, but I am no expert. Here is my question:

In most cases, our method of moving variables among pages has been to use "variablename=request.form("variablename")". I have learned that this means "look at the last page you processed and find this value". We do not have to put anything on the previous page to make this work.

However, occasionally that does not work. In those cases, you must put &quot;<input name=&quot;variablename&quot; type=&quot;hidden&quot; value=&quot;<%=variablename%>&quot;>&quot; under the button that moves the user from the first page to the second page.

The thing I don't understand is...why do some variables require a &quot;push&quot;, and others do not require it??? I can only determine whether to use the &quot;<input name...&quot; code by experimentation. If I use that code when it is NOT needed, I end up with two instances of the variable on the second page.
 
er. i am confused. what do u mean by &quot;push&quot;?

Known is handfull, Unknown is worldfull
 
same here...confused, can you explain more about push.

samir
 
I'm sorry. By &quot;push&quot; I mean using the &quot;<input name...&quot; tag on the first page. Sometimes you must include it. At other times, you just need the &quot;...request.form...&quot; on the second page. I don't understand that.
 
If I understand correctly, you are using the Request object to retrieve variables from the preceding page. You use Request.Form(&quot;varName&quot;) to retrieve any objects from the calling page form. This only works if you are using forms and &quot;POST&quot;ing from one page to the next. Also, it only retrieves variables from the form that calls the page. For example, if you have two forms on the first page, only one of them can call the next page and thus only variables from that one form will be retrievable on the next page as well. I guess an example may help:

Page one:
Code:
<body>
<form method=&quot;post&quot; action=&quot;Page2.asp&quot; name=&quot;frmOne&quot;>
<input type=&quot;text&quot; name=&quot;text1&quot; value=&quot;Something&quot;>
<input type=&quot;checkbox&quot; name=&quot;ckbox1&quot; value=&quot;thisCk&quot; checked>
<input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;btnFrmOne&quot;>
</form>

<form method=&quot;post&quot; action=&quot;Page2.asp&quot; name=&quot;frmTwo&quot;>
<input type=&quot;text&quot; name=&quot;text2&quot; value=&quot;Other&quot;>
<input type=&quot;hidden&quot; name=&quot;hide1&quot; value=&quot;Another&quot;>
<input type=&quot;submit&quot; value=&quot;Another submit&quot; name=&quot;btnFrmTwo&quot;>
</form>

Page 2:
Code:
<% 
for each obj in request.form
  response.write obj & &quot; is one of the objects from the form that was sent<br>&quot;
next
%>

What should happen is that you can call Page2 from either form in Page1, but only the values from that form will be visible in the second form (they will be iterated through in the short script here). Not sure if this answers your question or not, but hopefully gives you a general idea. For further information on the Request object, you can try DevGuru here:
-----------------------------------------------------------------------------------------------------
&quot;If you can't explain something to a six-year-old, you really don't understand it yourself.&quot;
-- Albert Einstein
 
Yeah, after looking at the code again, I think that your rules are accurate. I also see the source of my confusion.

Many of the form objects are very large and they have other objects inside of them. So we were able to pull over both things that we explicitly mentioned with &quot;<input type...&quot; AND things that just happened to be on that form for other reasons.

This project should not have used all of these local variables. We should have used session variables or cookies. Moving these values from page to page is very tedious.

Oh well, at least now I know the rule!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top