Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Displaying hyperlinks in ASP VBScript from mdb

Explorer ,
Jul 29, 2011 Jul 29, 2011

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.

TOPICS
Server side applications
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 29, 2011 Jul 29, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 29, 2011 Jul 29, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 29, 2011 Jul 29, 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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 30, 2011 Jul 30, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 30, 2011 Jul 30, 2011

Using DW is going to be extremely frustrating if you are not familiar with HTML and the server side scripting language you are using.

>What I am aiming at is to have the Title column displayed

>as hyperlinks using the info from the database.

The code I gave you was intended to do exactly that. It is very possible there is an error in that code. The error message you are getting is not very informative, probably because it is displaying a 'friendly' error message. To find out exactly where the problem is, you need to turn off friendly error messages in your browser and/or on the server. You may have to ask your host for help with changing this on the server. Do you have a url we can see?

> I have recoreded below all the code, the old and the new.

Just to be clear, the code I gave you is intended to replace everthing you have between (and including) the <table> tags. Is that what you did? It will not run if you have inserted it in the position you listed above.

>Is there no way to make a change using Dreamweaver 8 instead?

DW's server behavior's have very limited functionality and so I really don't use them. They always seems to perform 85% of the task, but then you need to hand code the rest. So you do really need to understand code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 30, 2011 Jul 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 30, 2011 Jul 30, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 31, 2011 Jul 31, 2011
LATEST

Many thanks for this and all of your help.

Kevin

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines