Forum Moderators: open

Message Too Old, No Replies

Passing form variables from 1 page to another

         

Andrew Thomas

5:21 pm on Nov 11, 2003 (gmt 0)

10+ Year Member



I have 3 pages 1.asp, 2.asp 3.asp accessed in that order only.

Page 1 uses a form called "formname"

Page 2 uses Request.form("formname") and works!

Page 3 uses Request.form("formname") but does not work.

If i bypass page 2 (for test purposes, page 3 works).

Im i using the wrong kind of variable, should i be using a session variable? If not whats wrong?

thanks

defanjos

5:45 pm on Nov 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You have to set the variable on 2.asp again, for example:

If you pass Request.form("delta") from 1.asp to 2.asp, you'll have to set a field named "delta" again on 2.asp
If you don't want it shown, the best way to do it, is to use a hidden form field.

Put this on the form of 2.asp:
<input type="hidden" name="delta" value="<%=request.form("delta")%>">

Now you can call request.form("delta") again on 3.asp

Andrew Thomas

4:00 pm on Nov 12, 2003 (gmt 0)

10+ Year Member



defanjos - Thanks, but it still doesnt seem to be working, here is the basics of what i have

Page 1 - bases.asp

<form name="base" method="post" action="cases.asp?<%= Request.ServerVariables("QUERY_STRING") %>">

' get a list of available bases and prices

<input name="chkbases" type="radio" id="chkbases" value="<%= (rs_base.Fields.Item("pc_base_model").Value)%><%=" "%><%=(rs_base.Fields.Item("pc_base_price").Value)%>">
</div></td>
<td width="53%"><div align="left"><%=(rs_base.Fields.Item("pc_base_model").Value)%></div></td>
<td width="39%"><div align="right"><%= FormatCurrency((rs_base.Fields.Item("pc_base_price").Value), 2, -2, -2, -2) %></div></td>
</tr>

Page 2 - cases.asp

b_model_result = Request.form("chkbases")

' code to get the value of pc_base_model

i = instrrev(b_model_result," ")
if ( i > 0 ) then
strModel = mid(b_model_result,1,i)
end if

' select statement to retreive more selction where the value equals the vlaue od pc_base_model

"SELECT blah.. blah.. blah..WHERE pc_base_model = '" & strModel & "' ;"

<%
str_bases = Request.form("chkbases")
response.Write(str_bases)
%>

Page 3 - diskdrives.asp

This is exactly the same as page 2, i need the same value pc_base_model which has been converted to str_model. from page 1.

But as i said before, this does not work, i know the SQL is correct because when i bypass page 2 and go straight from page 1 to page 3 it works fine.

defanjos - Ive looked at you example, but i still didnt get anywhere.

thanks for any help

too much information

4:42 pm on Nov 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know if this will help but I had a similar problem recently.

It looks like you are calling for the same table value twice on the page. What I found is <i>sometimes</i> this causes an error and the way to work around it is to set some temp variable to the table value the use the temp variable for the rest of the page.

i.e.
temp_price = rs_base.Fields.Item("pc_base_price").Value

I don't understand why this fixed my problem, but it did. In my opinion it's just extra work.

Also, how are you getting from page 2 to page 3? if page 2 is a form then using the <input type='hidden'> should work. If you are using a redirect to page 3 you need to pass your variables in the querystring instead of by form values. so you would use Request.querystring("variable") instead of the Request.form("variable") method.

defanjos

5:50 pm on Nov 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



disregard