Skip to main content
Inspiring
July 29, 2011
Question

Displaying hyperlinks in ASP VBScript from mdb

  • July 29, 2011
  • 1 reply
  • 1283 views

Hi

I am setting up a search facility using asp VBScript complete with mdb. My results page when displayed tabulates the title found OK and the link OK in two columns in my table (but the link doesn't work as a hyperlink).  But of course what I want is to have the title found displayed along with the hyperlink received from the mdb on hover over the title found in the table. I don't need the link displayed in a separate column but as a hyperlink on hover over the title found (the link doesn't work as a link anyway the way I have it set up at the moment). Can anyone help? Thanks.

This topic has been closed for replies.

1 reply

Participating Frequently
July 30, 2011

We need to see your code to see what you are doing wrong. What you want to achieve is pretty simple.

Inspiring
July 30, 2011

Hi

Here is the the code.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connSciWeb.asp" -->
<%
Dim rsSearch__MMColParam
rsSearch__MMColParam = "1"
If (Request.QueryString("search") <> "") Then
  rsSearch__MMColParam = Request.QueryString("search")
End If
%>
<%
Dim rsSearch
Dim rsSearch_numRows

Set rsSearch = Server.CreateObject("ADODB.Recordset")
rsSearch.ActiveConnection = MM_connSciWeb_STRING
rsSearch.Source = "SELECT KeyWords, Link, Title FROM Table1 WHERE KeyWords = '" + Replace(rsSearch__MMColParam, "'", "''") + "'"
rsSearch.CursorType = 0
rsSearch.CursorLocation = 2
rsSearch.LockType = 1
rsSearch.Open()

rsSearch_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
rsSearch_numRows = rsSearch_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Search Results</title>
<style type="text/css">
<!--
body {
     background-color: #FFFF00;
}
.style2 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; }
-->
</style></head>

<body>
<div align="center">
  <p> </p>
  <p> </p>
  <p> </p>
  <p> </p>
  <p> </p>
  <table border="1" cellpadding="1" cellspacing="1">
    <tr>
      <td width="185" bordercolor="#FF0000" bgcolor="#00FFFF"><div align="center" class="style2">KeyWord(s)</div></td>
      <td width="514" bordercolor="#FF0000" bgcolor="#00FFFF"><div align="center" class="style2">Link</div></td>
      <td width="220" bordercolor="#FF0000" bgcolor="#00FFFF"><div align="center" class="style2">Title</div></td>
    </tr>


    <% While ((Repeat1__numRows <> 0) AND (NOT rsSearch.EOF)) %>
      <tr>
        <td height="106" bordercolor="#FF0000" bgcolor="#00FFFF"><div align="center" class="style2"><%= UCase((rsSearch.Fields.Item("KeyWords").Value)) %></div></td>
        <td bordercolor="#FF0000" bgcolor="#00FFFF"><div align="center" class="style2"><%=(rsSearch.Fields.Item("Link").Value)%></div></td>
        <td bordercolor="#FF0000" bgcolor="#00FFFF"><div align="center" class="style2"><%= UCase((rsSearch.Fields.Item("Title").Value)) %></div></td>
      </tr>
      <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsSearch.MoveNext()
Wend
%>
  </table>
</div>
</body>
</html>
<%
rsSearch.Close()
Set rsSearch = Nothing
%>

Many thanks Kevin

Participating Frequently
July 30, 2011

Well done on this solution.

I was wondering if I needed to replace part of the original code with your suggestion. Then I needed to work out exactly which code of mine needed to go! The results page now works and displays the title and the link works on hover and then click. Great!

One bit of adjustment...

In my mdb table, I had the links placed in a 'hyperlink' field originally. In my results table the links come through with #.........# either end of the link, so the link did not work of course. I then, in my mdb table, changed the 'hyperlink' field to a 'text' field and this worked. Is this the usual thing which is best?

Many, many thanks again

Kevin


Hyperlink fields are only useful when you are using MS Access to display them - it will automatically transform the url to a hyperlink. Outside of Access, they don't do anything. So just store the url's in a text field.