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

Inspiring
July 30, 2011

A link is not a link until you make it one, and I don't see any anchor tags in your code. If you are simply storing the url in your database, then try this:

<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="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"><a href="<%=(rsSearch.Fields.Item("Link").Value)%>"><%= UCase((rsSearch.Fields.Item("Title").Value)) %></a></div></td>
      </tr>
      <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsSearch.MoveNext()
Wend
%>
  </table>


Hi

Thanks for this. Unfort I got an error message.

I am basically using Dreamweaver 8 to do all of the code so I am not up on my code skills.

I have added your suggested code at the end of what was already there set up by Dreamweaver.

The error message was:

An error occurred on the server when processing the URL. Please contact the system administrator. If you are the system administrator please click here to find out more about this error.

This was immediately followed by the headings of the table Key word(s) and Title. What I am aiming at is to have the Title column displayed as hyperlinks using the info from the database. I have recoreded below all the code, the old and the new. Is there no way to make a change using Dreamweaver 8 instead? Or is that only in ASP.NET and not ASP VBScript which I am using?

<%@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
%>

<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="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"><a href="<%=(rsSearch.Fields.Item("Link").Value)%>"><%= UCase((rsSearch.Fields.Item("Title").Value)) %></a></div></td>

      </tr>

      <%

  Repeat1__index=Repeat1__index+1

  Repeat1__numRows=Repeat1__numRows-1

  rsSearch.MoveNext()

Wend

%>

  </table>

Kevin