?
Solved

Go To Detail Page Passing Values but not getting picked up correctly on Detail Page

Posted on 2004-11-29
6
Medium Priority
?
273 Views
Last Modified: 2010-05-18
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_Connect.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = 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.QueryString(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.Form(MM_item))
  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">Description</font></strong></td>
    <td><font color="#666666">&nbsp;</font></td>
  </tr>
  <%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
  <tr>
    <td width="18%"><%=(Recordset1.Fields.Item("CatID").Value)%></td>
    <td width="65%"><%=(Recordset1.Fields.Item("CatDesc").Value)%></td>
    <td width="17%"><A HREF="sub_view.asp?<%= MM_keepURL & MM_joinChar(MM_keepURL) & "CatID=" & Recordset1.Fields.Item("CatID").Value %>">View</A></td>
  </tr>
  <%
  Repeat1__index=Repeat1__index+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_Connect.asp" -->
<%
Dim Recordset2__MMColParam
Recordset2__MMColParam = "1"
If (Request.QueryString("CatFID") <> "") Then
  Recordset2__MMColParam = Request.QueryString("CatFID")
End If
%>
<%
Dim Recordset2
Dim Recordset2_numRows

Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_DB_Connect_STRING
Recordset2.Source = "SELECT * FROM dbo.tblSubCat WHERE CatFID = " + Replace(Recordset2__MMColParam, "'", "''") + " 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</font></strong></td>
    <td><strong><font color="#666666">Sub Description</font></strong></td>
    <td><font color="#666666">&nbsp;</font></td>
  </tr>
  <%
While ((Repeat1__numRows <> 0) AND (NOT Recordset2.EOF))
%>
  <tr>
    <td><%=(Recordset2.Fields.Item("SubCatID").Value)%></td>
    <td><%=(Recordset2.Fields.Item("SubCatDesc").Value)%></td>
    <td>View</td>
  </tr>
  <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset2.MoveNext()
Wend
%>
</table>
</body>
</html>
<%
Recordset2.Close()
Set Recordset2 = Nothing
%>
0
Comment
Question by:jay_eire
  • 4
  • 2
6 Comments
 
LVL 10

Accepted Solution

by:
rockmansattic earned 2000 total points
ID: 12695763
You are useing two different variabls

change sub_page

<%
Dim Recordset2__MMColParam
Recordset2__MMColParam = "1"
If (Request.QueryString("CatFID") <> "") Then
  Recordset2__MMColParam = Request.QueryString("CatFID")
End If
%>

to

<%
Dim Recordset2__MMColParam
Recordset2__MMColParam = "1"
If (Request.QueryString("CatID") <> "") Then
  Recordset2__MMColParam = Request.QueryString("CatID")
End If
%>

******OR****
main_page

"><A HREF="sub_view.asp?<%= MM_keepURL & MM_joinChar(MM_keepURL) & "CatID=" & Recordset1.Fields.Item("CatID").Value %>">View</A>

to

"><A HREF="sub_view.asp?<%= MM_keepURL & MM_joinChar(MM_keepURL) & "CatFID=" & Recordset1.Fields.Item("CatID").Value %>">View</A>

Rockman
0
 
LVL 10

Expert Comment

by:rockmansattic
ID: 12695773
your main page is sending a CatID, but your sub_page is looking for CatDIF.


rockman
0
 
LVL 7

Author Comment

by:jay_eire
ID: 12695794
yes i know, its ment to do that CATFID is the foreign key to CATID.......
0
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

 
LVL 10

Expert Comment

by:rockmansattic
ID: 12695842
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
0
 
LVL 7

Author Comment

by:jay_eire
ID: 12696071
my fault, i see what your getting at now, thank for your help man!
0
 
LVL 10

Expert Comment

by:rockmansattic
ID: 12696162
no problem, sometimes it is hard to explain without moving may hands wildly in the air.

Rockman
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question