Passing Value Question

D

Dthmtlgod

I am having a little difficulty in passing a value from a page to another
page. I am going to provide excerpts from the code. I think I am close.

This is from Page1.ASP

<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtest=dsntest & "DBQ=" & Server.MapPath("ncci.mdb")
Conn.Open DSNtest

Set rs = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT Distinct Insured FROM CCI2"
rs.Open strSQL, conn, 3, 3
%>

<TABLE>

<tr>
<td width=200>
<select
onchange="parent.fSearch1.location.href='Search1.asp?Ins='+this.value;"
size="1">

This passes the INS value to Page 2.ASP after something is selected (code
not shown)

This is from Page 2.ASP

insName = Request.QueryString("Ins")

Function sIn(s)
sIn = "'" & Replace(s, "'", "''") & "'"
End Function

Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtest=dsntest & "DBQ=" & Server.MapPath("cci.mdb")
Conn.Open DSNtest

Set rs = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT Distinct State FROM CCI2 where Insured = " & sIn(insName) &
";"
rs.Open strSQL, conn, 3, 3

This works as it should up to this point.

I am trying to pass insName to Page 3.ASP
I have tried this inside my form.

<%
response.write"<input type=hidden name=insName value='" & insName & "'>"
%>

This is from Page 3.ASP

insName = Request.form("insName")

Then I am just trying to display it using the below code and it doesn't see
it.

response.write(insName)


Please help.
 
R

Ray Costanzo [MVP]

Does the <form> tag on page2.asp say method="post" or method="get"?
If method="post", all should be okay. (Show us page2.asp if that's
the case.) If it's method="get", then use
Request.Querystring("insName") instead of Request.Form.
 
D

Dthmtlgod

Hi Ray, here you go

Here is Page 2

<body>

<%@ LANGUAGE="VBSCRIPT" %>

<%

insName = Request.QueryString("Ins") ---- This was from a previous page.

Function sIn(s)
sIn = "'" & Replace(s, "'", "''") & "'"
End Function

Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtest=dsntest & "DBQ=" & Server.MapPath("cci.mdb")
Conn.Open DSNtest

Set rs = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT Distinct State FROM CCI2 where Insured = " & sIn(insName) &
";"
rs.Open strSQL, conn, 3, 3

%>

<table border="0" cellspacing="0" cellpadding="0">
<form name="formSearch1" action="http://cci/home.html" method="post">
<tr>
<td><b>Filter(s):</b>&nbsp;</td>
<td>
<select name="state"
onchange="parent.fSearch2.location.href='Search2.asp?St='+this.value;"
size="1">
<option value="">Select a State</option>

<%
While NOT RS.EOF
%>
<div><font size=1>
<center>
<option value="<%=RS("State")%>"><%=RS("State")%></option>
</center>
</font>
</div>
<%
RS.MoveNext
WEND
%>

</select>
</td>
</tr>

<%
response.write"<input type=hidden name=insName value='" & insName & "'>"
%>

</form>
</table>

</body>

Page 3

<%@ LANGUAGE="VBSCRIPT" %>
<!-- METADATA TYPE="typelib" FILE="c:\program files\common
files\system\ado\msado15.dll" -->

<%

rState = Request.QueryString("St")
insName = Request.Form("insName")

Function sIn(s)
sIn = "'" & Replace(s, "'", "''") & "'"
End Function

response.write("<H3>")
response.write("<CENTER>")
response.write(sIn(insName))
response.write("</center>")
response.write("</H3>")

......
 
R

Ray Costanzo [MVP]

You're posting to a .html page? Do you have IIS configured to
process .html pages with ASP.dll? Page3 in your sample is home.html?

--

Ray at work
Microsoft ASP/ASP.NET MVP
 
D

Dthmtlgod

I was trying to reload the page. I am not sure if it is configured process
HTML as ASP pages, but I just changed my home page to home.asp and changed
the code to reflect "home.asp", but it is still not passing the value.


Home.HTML is my main page

<frameset cols="235,*" framespacing="0">
<frame name="fLeft" src="Left.ASP" frameborder="no">
<frameset rows="2,25" framespacing="0">
<frame name="fSearch1" src="Search1.ASP" frameborder="no" noresize
scrolling="no">
<frame name="fSearch2" src="Search2.ASP" frameborder="no" noresize
scrolling="yes">
<noframes>
<p>This page requires frames, but your browser does not support them.</p>
</noframes>
</frameset>
</frameset>
 
R

Ray Costanzo [MVP]

You're not trying to get that value after your location.href code
executes, are you?

Put this in home.asp:

<%
Response.write Request.ServerVariables("request_method") & "<hr>"
For each thing in REquest.form
Response.write thing & " = " & request.form(thing) & "<br>"
Next
%>

Please post back the results that appear in the browser.

--

Ray at work
Microsoft ASP/ASP.NET MVP


Dthmtlgod said:
I was trying to reload the page. I am not sure if it is configured process
HTML as ASP pages, but I just changed my home page to home.asp and changed
the code to reflect "home.asp", but it is still not passing the value.


Home.HTML is my main page

<frameset cols="235,*" framespacing="0">
<frame name="fLeft" src="Left.ASP" frameborder="no">
<frameset rows="2,25" framespacing="0">
<frame name="fSearch1" src="Search1.ASP" frameborder="no" noresize
scrolling="no">
<frame name="fSearch2" src="Search2.ASP" frameborder="no" noresize
scrolling="yes">
<noframes>
<p>This page requires frames, but your browser does not support
 
D

Dthmtlgod

Yes, I was eventually, maybe I am doing it the wrong way.

I put the code in and "GET" comes up.
 
D

Dthmtlgod

What I am trying to accomplish is have two option boxes, the second box
bring up data based on what is selected in the first box. I was trying to
do this over three frames.

I have modified my code a bit, the two option boxes are in the same frame
and I want to return the results into another frame, cut out the second
frame altogether. So I should probably use a submit button maybe to
accomplish this?

Thanks for your patience.
 
R

Ray Costanzo [MVP]

Alright, in that case, there is no request.form collection, because
you're not posting data. You're just making another GET request to
the server. The hidden input value will not exist in the form (or
the querystring for that matter) if a form is not submitted. Instead
of putting insName in a hidden input, put it in the querystring of
the location.href argument. Example:

onchange="parent.fSearch2.location.href='insname=<%=insName%>&Search2
..asp?St='+this.value;"

--

Ray at work
Microsoft ASP/ASP.NET MVP
 
D

Dthmtlgod

Thanks

Ray Costanzo said:
Alright, in that case, there is no request.form collection, because
you're not posting data. You're just making another GET request to
the server. The hidden input value will not exist in the form (or
the querystring for that matter) if a form is not submitted. Instead
of putting insName in a hidden input, put it in the querystring of
the location.href argument. Example:

onchange="parent.fSearch2.location.href='insname=<%=insName%>&Search2
.asp?St='+this.value;"
 
D

Dthmtlgod

Hi Ray,

I am trying to use your statement below and I am getting a Page Can't Be
Displayed error

onchange="parent.fSearch2.location.href='insname=<%=insName%>&Search2
..asp?St='+this.value;"

Search2.ASP exists.

Any ideas?
 
R

Ray Costanzo [MVP]

I guess that means that what I post should be proof-read. Notice
that I forgot to inclue a page name in the .href property.
..href='PAGE.ASP?insname...'

--

Ray at work
Microsoft ASP/ASP.NET MVP


Dthmtlgod said:
Hi Ray,

I am trying to use your statement below and I am getting a Page Can't Be
Displayed error
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top