Bookmarkable Anchor

Hi,

The following code is working 100%.  But,  it creates an anchor each time a search is done.

Suppose I searched for a CustomerID BLONP it finds it and creates a temporay anchor that can not be bookmarked.

How to make the page bookmarkable so next time I open it,  it will go to that ID BLONP which I searched for.


<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body onLoad="window.navigate('IDHL6.asp#FoundID');">
<form method="POST" action="IDHL6.asp#FoundID">
  <p>Country: <input type="text" name="CustomerID" size="20"></p>
  <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2">
  <a href="IDHL5.asp">All</a></p>
</form>
<BR>
<%
last_visable_record=23
CustID=request.form("CustomerID")
Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("fpdb/Northwind.mdb")
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"
SQL_query = "SELECT * FROM Customers"
Set RS = MyConn.Execute(SQL_query)
%>

 <table align="center" border="1" cellpadding="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111" width="500" id="AutoNumber1">
  <tr>
    <td align="center" bgcolor="#000080"><B><font color="#FFFFFF">Customer ID</font></B></td>
    <td align="center" bgcolor="#000080"><B><font color="#FFFFFF">Contact Name</font></B></td>
    <td align="center" bgcolor="#000080"><B><font color="#FFFFFF">Contact Title</font></B></td>
    <td align="center" bgcolor="#000080"><B><font color="#FFFFFF">Country</font></B></td>

  </tr>
<%
function countMatches(sSearchParam, activeConnection)
  Dim lRetCount
  lRetCount = ""
  if len(sSearchParam)>0 then
    Dim rsCount
    Dim sSQL
    sSQL = "SELECT COUNT(1) AS CountResults FROM Customers WHERE CustomerID='"&replace(sSearchParam, "'", "''")&"'"
    set rsCount = server.createobject("adodb.recordset")
    rsCount.open sSQL, activeConnection, 1, 3, 1
    lRetCount = rsCount.fields("CountResults")
    rsCount.close
    set rsCount=nothing
  end if
  countMatches = lRetCount
end function
%>


<%
Dim sBGColor
  Dim sAnchor
 if len(request("CustomerID"))>0 then
 if countMatches(request("CustomerID"), MyConn)=0 then
    response.write "There were no records returned by your search. Please try again."
 end if
end if

    do WHILE NOT RS.EOF
      count = count + 1
      sAnchor = "" 
      if UCASE(trim(CustID)) = UCASE(trim(RS("CustomerID"))) then
        sBGColor = " bgcolor=yellow"
        if count > last_visable_record then
          sAnchor = "<A NAME=""FoundID""></A>"
          end if
      else
        sBGColor = ""
      end if
     
%>
  <tr<%=sBGColor%>>
        <td align="left"><%=sAnchor%>&nbsp;<% =RS("CustomerID")%>&nbsp;</td>
        <td align="left">&nbsp;<% =RS("ContactName")%>&nbsp;</td>
        <td align="left">&nbsp;<% =RS("ContactTitle")%>&nbsp;</td>
        <td align="left">&nbsp;<% =RS("Country")%>&nbsp;</td>
      </tr>
<%
      RS.MoveNext
    loop
%>


</table>
</body>

</html>


Thanks
LVL 14
hhammashAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mk_bCommented:
Try changing the form from a POST to a GET and then where ever you got request.form to Request.Querystring

so when the person bookmarks the page it will be IDHL6.asp?CustomerID=what#FoundID

that way when the come back to the site the search will be run automaticly and the page will jusp to the right place..

in theory of course..

../mk

Try this it worked for me...


<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body onload="window.location='#FoundID';">
<form method="get" action="IDHL5.asp#FoundID">
  <p>Country: <input type="text" name="CustomerID" size="20"></p>
  <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2">
  <input type="hidden" name="anchor" value="#FoundID"
  <a href="IDHL5.asp">All</a></p>
</form>
<BR>
<%
last_visable_record=23
CustID=request("CustomerID")
Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("fpdb/Northwind.mdb")
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"
SQL_query = "SELECT * FROM Customers"
Set RS = MyConn.Execute(SQL_query)
%>

 <table align="center" border="1" cellpadding="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111" width="500" id="AutoNumber1">
  <tr>
    <td align="center" bgcolor="#000080"><B><font color="#FFFFFF">Customer ID</font></B></td>
    <td align="center" bgcolor="#000080"><B><font color="#FFFFFF">Contact Name</font></B></td>
    <td align="center" bgcolor="#000080"><B><font color="#FFFFFF">Contact Title</font></B></td>
    <td align="center" bgcolor="#000080"><B><font color="#FFFFFF">Country</font></B></td>

  </tr>
<%
function countMatches(sSearchParam, activeConnection)
  Dim lRetCount
  lRetCount = ""
  if len(sSearchParam)>0 then
    Dim rsCount
    Dim sSQL
    sSQL = "SELECT COUNT(1) AS CountResults FROM Customers WHERE CustomerID='"&replace(sSearchParam, "'", "''")&"'"
    set rsCount = server.createobject("adodb.recordset")
    rsCount.open sSQL, activeConnection, 1, 3, 1
    lRetCount = rsCount.fields("CountResults")
    rsCount.close
    set rsCount=nothing
  end if
  countMatches = lRetCount
end function
%>


<%
Dim sBGColor
  Dim sAnchor
 if len(request("CustomerID"))>0 then
 if countMatches(request("CustomerID"), MyConn)=0 then
    response.write "There were no records returned by your search. Please try again."
 end if
end if

    do WHILE NOT RS.EOF
      count = count + 1
      sAnchor = "" 
      if UCASE(trim(CustID)) = UCASE(trim(RS("CustomerID"))) then
        sBGColor = " bgcolor=yellow"
        if count > last_visable_record then
          sAnchor = "<A NAME=""FoundID""></A>"
          end if
      else
        sBGColor = ""
      end if
     
%>
  <tr<%=sBGColor%>>
        <td align="left"><%=sAnchor%>&nbsp;<% =RS("CustomerID")%>&nbsp;</td>
        <td align="left">&nbsp;<% =RS("ContactName")%>&nbsp;</td>
        <td align="left">&nbsp;<% =RS("ContactTitle")%>&nbsp;</td>
        <td align="left">&nbsp;<% =RS("Country")%>&nbsp;</td>
      </tr>
<%
      RS.MoveNext
    loop
%>


</table>
</body>

</html>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hhammashAuthor Commented:
Hi Mk,

It is working fine with no problem, but I will show you what appears on the addres bar:

http://residenc-9c69f0/Pictures4/BookMarkableAnchor.asp?CustomerID=Consh&B1=Submit&anchor=%23FoundID#FoundID

Why is the B1=Submit (the form button is mentioend)?
Why #FoundID is mentioned.  The correct URL which is enough is
http://residenc-9c69f0/Pictures4/BookMarkableAnchor.asp?CustomerID=Consh

Why is this addition?
&B1=Submit&anchor=%23FoundID#FoundID

How can the Code generate this URL only:
http://residenc-9c69f0/Pictures4/BookMarkableAnchor.asp?CustomerID=Consh


Thank you
hhammash
0
mk_bCommented:
when you use "GET" in a form it passes all the form ellements so it will pass the button with it?

you need the anchor=FoundID#FoundID so that it will just to the right place?

I dont know if you are going to be able to get the url to look the way you want? If someone bookmarks the page they will see the <title>My Page</title> anyway...

../mk
0
hhammashAuthor Commented:
Thank you MK_b
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.