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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Breadcrumb

Status
Not open for further replies.

Figzus

Programmer
Mar 21, 2005
36
US
Okay so I have this breadcrumb for VB Script. When the user hits back it will take them to the previous crumb id. What Im trying to do is when they hit that back button it takes out the last crumb/id out of it completely so when they go forward again to a different area the previous spot is no longer there. Any help would be great thanks. Here is my code.

<%
'Function for creation of breadcumb trails
Public Function BuildCrumb(Title)
Response.CacheControl = "no-cache"
Dim Separator
Separator = " | "
Dim GetPage
GetPage = Split(Request.ServerVariables("PATH_INFO"), "/")
Dim PageLink

For Each var In Request.Querystring
PageLink = "<a href=" & GetPage(Ubound(GetPage)) & "?" & var & "=" & Request.Querystring(var)
Next
Set var = Nothing

If PageLink = "" then
PageLink = "<a href=" & GetPage(Ubound(GetPage)) & " class=crumb>" & Title & "</a>"
Else
PageLink = PageLink & " class=crumb>" & Title & "</a>"
End If

If Request.Cookies("Crumb") <> "" Then
Dim GetCurrentPageTitle
GetCurrentPageTitle = Split(Request.Cookies("Crumb"), " | ")
If InStr(Request.Cookies("Crumb"), PageLink) = 0 then
Response.Cookies("Crumb") = Request.Cookies("Crumb") & Separator & PageLink
Else
For i = 0 To UBound(GetCurrentPageTitle)
If PageLink <> Trim(GetCurrentPageTitle(i)) Then
Crumb = Crumb & Trim(GetCurrentPageTitle(i)) & Separator
Else
i = UBound(GetCurrentPageTitle)
End If
Next
Response.Cookies("Crumb") = ""
Response.Cookies("Crumb") = Crumb & PageLink
Set Crumb = Nothing
Set i = Nothing
End If
Else
Response.Cookies("Crumb") = "<a href=MDCLibrary.asp class=crumb>MDC Library Home</a>" & Separator & PageLink
End If
Response.Cookies("Crumb").Expires = Dateadd("d", 1, Date)
Set GetCurrentPageTitle = Nothing
Set PageLink = Nothing
Set GetPage = Nothing
Set Separator = Nothing
End Function

'Reset the breacrumb trail to start another
Public Function RestartCrumb()
Response.Cookies("Crumb") = ""
End Function
%>



 
I didn't really study the code but I noticed this one thing right off...

It looks like the value of PageLink will be overwritten each time through your For Next loop so it will end up with only the value from the last time through the loop.
Code:
Dim PageLink

For Each var In Request.Querystring
  PageLink = "<a href=" & GetPage(Ubound(GetPage)) & "?" & var & "=" & Request.Querystring(var)
Next
Set var = Nothing

 
Yeah I know that its just when you hit back it will erase it from the text until you hit another value then it will reappear. Ive been trying to get it so when you click back it will erase it from the the For Next Loop.
 
After some testing I have figured out that when I do a refresh it clears the previous value out. I just have to figure out how to do a refresh or clear out my cache everytime I click the back buttton.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top