jay_eire
asked on
Go To Detail Page Passing Values but not getting picked up correctly on Detail Page
Hi Guys,
I have two pages the first called main_view.asp and the second is called Sub_View.asp i am using repated regions on both pages.
on the main_view.asp page i am using a "Go To Detail Page" link to link to Sub_View.asp im passing the CATID to this page to select everything from the table tblSubCat where the ID is equal to 3 for example, depending on which category the user selects on main_view.asp.
the SQL bit works, and when i test it in the recordset window in the dreamweaver it works, BUT when i go to my browser and test it, it keeps returning back the first record in the database everytime! no matter what link i click, even though in the browser address bar the URL changes eg: http://mysite/Sub_View.asp?CatID=3
please help!
Thanks
Jay Eire
(<>..<>)
************************** ********** Main View ************************** **********
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/DB_Conne ct.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB .Recordset ")
Recordset1.ActiveConnectio n = MM_DB_Connect_STRING
Recordset1.Source = "SELECT * FROM dbo.tblCat ORDER BY CatDesc ASC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
Dim MM_paramName
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth
Dim MM_removeList
Dim MM_item
Dim MM_nextItem
' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If
MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""
' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_ nextItem,1 ) = 0) Then
MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.Q ueryString (MM_item))
End If
Next
' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_ nextItem,1 ) = 0) Then
MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.F orm(MM_ite m))
End If
Next
' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then
MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "") Then
MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If
' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Main View</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr bgcolor="#CCCCCC">
<td><strong><font color="#666666">ID</font>< /strong></ td>
<td><strong><font color="#666666">Descriptio n</font></ strong></t d>
<td><font color="#666666"> </fo nt></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td width="18%"><%=(Recordset1 .Fields.It em("CatID" ).Value)%> </td>
<td width="65%"><%=(Recordset1 .Fields.It em("CatDes c").Value) %></td>
<td width="17%"><A HREF="sub_view.asp?<%= MM_keepURL & MM_joinChar(MM_keepURL) & "CatID=" & Recordset1.Fields.Item("Ca tID").Valu e %>">View</A></td>
</tr>
<%
Repeat1__index=Repeat1__in dex+1
Repeat1__numRows=Repeat1__ numRows-1
Recordset1.MoveNext()
Wend
%>
</table>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
************************** ********** Sub View ************************** **********
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/DB_Conne ct.asp" -->
<%
Dim Recordset2__MMColParam
Recordset2__MMColParam = "1"
If (Request.QueryString("CatF ID") <> "") Then
Recordset2__MMColParam = Request.QueryString("CatFI D")
End If
%>
<%
Dim Recordset2
Dim Recordset2_numRows
Set Recordset2 = Server.CreateObject("ADODB .Recordset ")
Recordset2.ActiveConnectio n = MM_DB_Connect_STRING
Recordset2.Source = "SELECT * FROM dbo.tblSubCat WHERE CatFID = " + Replace(Recordset2__MMColP aram, "'", "''") + " ORDER BY SubCatDesc ASC"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
Recordset2_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
Recordset2_numRows = Recordset2_numRows + Repeat1__numRows
%>
<html>
<head>
<title>Sub View</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr bgcolor="#CCCCCC">
<td><strong><font color="#666666">SubID</fon t></strong ></td>
<td><strong><font color="#666666">Sub Description</font></strong ></td>
<td><font color="#666666"> </fo nt></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset2.EOF))
%>
<tr>
<td><%=(Recordset2.Fields. Item("SubC atID").Val ue)%></td>
<td><%=(Recordset2.Fields. Item("SubC atDesc").V alue)%></t d>
<td>View</td>
</tr>
<%
Repeat1__index=Repeat1__in dex+1
Repeat1__numRows=Repeat1__ numRows-1
Recordset2.MoveNext()
Wend
%>
</table>
</body>
</html>
<%
Recordset2.Close()
Set Recordset2 = Nothing
%>
I have two pages the first called main_view.asp and the second is called Sub_View.asp i am using repated regions on both pages.
on the main_view.asp page i am using a "Go To Detail Page" link to link to Sub_View.asp im passing the CATID to this page to select everything from the table tblSubCat where the ID is equal to 3 for example, depending on which category the user selects on main_view.asp.
the SQL bit works, and when i test it in the recordset window in the dreamweaver it works, BUT when i go to my browser and test it, it keeps returning back the first record in the database everytime! no matter what link i click, even though in the browser address bar the URL changes eg: http://mysite/Sub_View.asp?CatID=3
please help!
Thanks
Jay Eire
(<>..<>)
**************************
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/DB_Conne
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB
Recordset1.ActiveConnectio
Recordset1.Source = "SELECT * FROM dbo.tblCat ORDER BY CatDesc ASC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
Dim MM_paramName
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth
Dim MM_removeList
Dim MM_item
Dim MM_nextItem
' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If
MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""
' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_
MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.Q
End If
Next
' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_
MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.F
End If
Next
' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then
MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "") Then
MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If
' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Main View</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr bgcolor="#CCCCCC">
<td><strong><font color="#666666">ID</font><
<td><strong><font color="#666666">Descriptio
<td><font color="#666666"> </fo
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td width="18%"><%=(Recordset1
<td width="65%"><%=(Recordset1
<td width="17%"><A HREF="sub_view.asp?<%= MM_keepURL & MM_joinChar(MM_keepURL) & "CatID=" & Recordset1.Fields.Item("Ca
</tr>
<%
Repeat1__index=Repeat1__in
Repeat1__numRows=Repeat1__
Recordset1.MoveNext()
Wend
%>
</table>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
**************************
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/DB_Conne
<%
Dim Recordset2__MMColParam
Recordset2__MMColParam = "1"
If (Request.QueryString("CatF
Recordset2__MMColParam = Request.QueryString("CatFI
End If
%>
<%
Dim Recordset2
Dim Recordset2_numRows
Set Recordset2 = Server.CreateObject("ADODB
Recordset2.ActiveConnectio
Recordset2.Source = "SELECT * FROM dbo.tblSubCat WHERE CatFID = " + Replace(Recordset2__MMColP
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
Recordset2_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
Recordset2_numRows = Recordset2_numRows + Repeat1__numRows
%>
<html>
<head>
<title>Sub View</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr bgcolor="#CCCCCC">
<td><strong><font color="#666666">SubID</fon
<td><strong><font color="#666666">Sub Description</font></strong
<td><font color="#666666"> </fo
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset2.EOF))
%>
<tr>
<td><%=(Recordset2.Fields.
<td><%=(Recordset2.Fields.
<td>View</td>
</tr>
<%
Repeat1__index=Repeat1__in
Repeat1__numRows=Repeat1__
Recordset2.MoveNext()
Wend
%>
</table>
</body>
</html>
<%
Recordset2.Close()
Set Recordset2 = Nothing
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes i know, its ment to do that CATFID is the foreign key to CATID.......
No..
the sub page is searching the database with the wrong variable.
the url var is CatID
the searching var is CatFID
when you get to the sub page, since there is NO CATFID variable, the default is 1, which is why you are getting the first record every time.
change the url to this and see
http://mysite/Sub_View.asp?CatFID=3
Rockman
the sub page is searching the database with the wrong variable.
the url var is CatID
the searching var is CatFID
when you get to the sub page, since there is NO CATFID variable, the default is 1, which is why you are getting the first record every time.
change the url to this and see
http://mysite/Sub_View.asp?CatFID=3
Rockman
ASKER
my fault, i see what your getting at now, thank for your help man!
no problem, sometimes it is hard to explain without moving may hands wildly in the air.
Rockman
Rockman
rockman