---
title: "Hru öppnar man"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/118214-hru-öppnar-man"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "Krister"
published: "2004-12-17T07:30:49.000Z"
updated: "2004-12-17T22:19:45.000Z"
replies: 10
views: 436
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/118214-hru-öppnar-man"
---

# Hru öppnar man

## #1 — Krister, 2004-12-17T07:30Z

Jag har en Access databas med växter ID, namn, text och bild.
På sidan vill jag att  alla namn ska synas och när man klickar på namnet så skall resp växt och bild visas.

Jag lyckas med allt utom att få klickbara namn.

Jag använder dreamweaver där det säkert finns någon klurig funktion som man kan lägga till eller någon har en liten kod så att det funkar.

Permalänk: https://www.webforum.nu/p/118214

## #2 — @nders, 2004-12-17T07:31Z

Hur ser din kod ut?

Permalänk: https://www.webforum.nu/p/1508291

## #3 — Krister, 2004-12-17T07:37Z

\<%
Dim rsblom
Dim rsblom_numRows

Set rsblom = Server.CreateObject("ADODB.Recordset")
rsblom.ActiveConnection = MM_cntrgdrom1_STRING
rsblom.Source = "SELECT Namn, Text, bild FROM vaxter"
rsblom.CursorType = 0
rsblom.CursorLocation = 2
rsblom.LockType = 1
rsblom.Open()

rsblom_numRows = 0
%\>
\<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsblom_numRows = rsblom_numRows + Repeat1__numRows
%\>
\<%
'  \*\*\* Recordset Stats, Move To Record, and Go To Record: declare stats variables

Dim rsblom_total
Dim rsblom_first
Dim rsblom_last

' set the record count
rsblom_total = rsblom.RecordCount

' set the number of rows displayed on this page
If (rsblom_numRows \< 0) Then
  rsblom_numRows = rsblom_total
Elseif (rsblom_numRows = 0) Then
  rsblom_numRows = 1
End If

' set the first and last displayed record
rsblom_first = 1
rsblom_last  = rsblom_first + rsblom_numRows - 1

' if we have the correct record count, check the other stats
If (rsblom_total \<\> -1) Then
  If (rsblom_first \> rsblom_total) Then
    rsblom_first = rsblom_total
  End If
  If (rsblom_last \> rsblom_total) Then
    rsblom_last = rsblom_total
  End If
  If (rsblom_numRows \> rsblom_total) Then
    rsblom_numRows = rsblom_total
  End If
End If
%\>

\<%
Dim MM_paramName 
%\>
\<%
' \*\*\* Move To Record and Go To Record: declare variables

Dim MM_rs
Dim MM_rsCount
Dim MM_size
Dim MM_uniqueCol
Dim MM_offset
Dim MM_atTotal
Dim MM_paramIsDefined

Dim MM_param
Dim MM_index

Set MM_rs    = rsblom
MM_rsCount   = rsblom_total
MM_size      = rsblom_numRows
MM_uniqueCol = "Namn"
MM_paramName = "id"
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName \<\> "") Then
  MM_paramIsDefined = (Request.QueryString(MM_paramName) \<\> "")
End If
%\>
\<%
' \*\*\* Move To Specific Record: handle detail parameter

If (MM_paramIsDefined And MM_rsCount \<\> 0) Then

  ' get the value of the parameter
  MM_param = Request.QueryString(MM_paramName)

  ' find the record with the unique column value equal to the parameter value
  MM_offset = 0
  Do While (Not MM_rs.EOF)
    If (CStr(MM_rs.Fields.Item(MM_uniqueCol).Value) = MM_param) Then
      Exit Do
    End If
    MM_offset = MM_offset + 1
    MM_rs.MoveNext
  Loop

  ' if not found, set the number of records and reset the cursor
  If (MM_rs.EOF) Then
    If (MM_rsCount \< 0) Then
      MM_rsCount = MM_offset
    End If
    If (MM_size \< 0 Or MM_size \> MM_offset) Then
      MM_size = MM_offset
    End If
    MM_offset = 0

    ' reset the cursor to the beginning
    If (MM_rs.CursorType \> 0) Then
      MM_rs.MoveFirst
    Else
      MM_rs.Close
      MM_rs.Open
    End If
  End If

End If
%\>
\<%
' \*\*\* Move To Record: if we dont know the record count, check the display range

If (MM_rsCount = -1) Then

  ' walk to the end of the display range for this page
  MM_index = MM_offset
  While (Not MM_rs.EOF And (MM_size \< 0 Or MM_index \< MM_offset + MM_size))
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend

  ' if we walked off the end of the recordset, set MM_rsCount and MM_size
  If (MM_rs.EOF) Then
    MM_rsCount = MM_index
    If (MM_size \< 0 Or MM_size \> MM_rsCount) Then
      MM_size = MM_rsCount
    End If
  End If

  ' if we walked off the end, set the offset based on page size
  If (MM_rs.EOF And Not MM_paramIsDefined) Then
    If (MM_offset \> MM_rsCount - MM_size Or MM_offset = -1) Then
      If ((MM_rsCount Mod MM_size) \> 0) Then
        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
      Else
        MM_offset = MM_rsCount - MM_size
      End If
    End If
  End If

  ' reset the cursor to the beginning
  If (MM_rs.CursorType \> 0) Then
    MM_rs.MoveFirst
  Else
    MM_rs.Requery
  End If

  ' move the cursor to the selected record
  MM_index = 0
  While (Not MM_rs.EOF And MM_index \< MM_offset)
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend
End If
%\>
\<%
' \*\*\* Move To Record: update recordset stats

' set the first and last displayed record
rsblom_first = MM_offset + 1
rsblom_last  = MM_offset + MM_size

If (MM_rsCount \<\> -1) Then
  If (rsblom_first \> MM_rsCount) Then
    rsblom_first = MM_rsCount
  End If
  If (rsblom_last \> MM_rsCount) Then
    rsblom_last = MM_rsCount
  End If
End If

' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount \<\> -1 And MM_offset + MM_size \>= MM_rsCount)
%\>
\<%
' \*\*\* Recordset Stats: if we don't know the record count, manually count them

If (rsblom_total = -1) Then

  ' count the total records by iterating through the recordset
  rsblom_total=0
  While (Not rsblom.EOF)
    rsblom_total = rsblom_total + 1
    rsblom.MoveNext
  Wend

  ' reset the cursor to the beginning
  If (rsblom.CursorType \> 0) Then
    rsblom.MoveFirst
  Else
    rsblom.Requery
  End If

  ' set the number of rows displayed on this page
  If (rsblom_numRows \< 0 Or rsblom_numRows \> rsblom_total) Then
    rsblom_numRows = rsblom_total
  End If

  ' set the first and last displayed record
  rsblom_first = 1
  rsblom_last = rsblom_first + rsblom_numRows - 1
  
  If (rsblom_first \> rsblom_total) Then
    rsblom_first = rsblom_total
  End If
  If (rsblom_last \> rsblom_total) Then
    rsblom_last = rsblom_total
  End If

End If
%\>
\<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"\>
\<html\>
\<head\>
\<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"\>
\<title\>Untitled Document\</title\>
\<script language="JavaScript" type="text/JavaScript"\>
\<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW \|\| innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//--\>
\</script\>
\</head\>

\<body\>

\<div id="Layer2" style="position:absolute; left:40px; top:80px; width:370px; height:160px; z-index:2; overflow: auto;"\>\<%=(rsblom.Fields.Item("Text").Value)%\>\</div\>
\<div id="Layer3" style="position:absolute; left:410px; top:50px; width:158px; height:160px; z-index:3"\>\<%=(rsblom.Fields.Item("bild").Value)%\>\</div\>

\<% 
While ((Repeat1__numRows \<\> 0) AND (NOT rsblom.EOF)) 
%\>
\<a href="#"\>\<%=(rsblom.Fields.Item("Namn").Value)%\> \</a\>
\<% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsblom.MoveNext()
Wend
%\>
\</body\>
\</html\>
\<%
rsblom.Close()
Set rsblom = Nothing
%\>

Permalänk: https://www.webforum.nu/p/1508295

## #4 — J.N., 2004-12-17T09:56Z

HEJ!

Ojjj, vad mycket ovidkommande kod, gör det endast värre att snabbt att ge ett råd. (Använd kod-taggarna också!)

Leta upp var namnet skrivs ut, lägg till en helt vanlig html-länk, sedan gör du om den till asp-varianten istället. Metodiskt alltså.

Jag tror det är denna kod som ska ändras

```
<a href="#"><%=(rsblom.Fields.Item("Namn").Value)%></a>
till
<a href="sida.asp?id=<%=(rsblom.Fields.Item("id").Value)%>" target="_blank"><%=(rsblom.Fields.Item("Namn").Value)%></a>
```

Sedan tar du emot värdet id på nästa sida, och hämtar just den posten i databasen.

Permalänk: https://www.webforum.nu/p/1508341

## #5 — Krister, 2004-12-17T10:41Z

Det funkar nästan bara att det inte byter text och bild
så här ser koden ut nu
\<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%\>
\<!--#include virtual="/Connections/cntrgdrom1.asp" --\>
\<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_cntrgdrom1_STRING
Recordset1.Source = "SELECT ID, Namn, Text, bild FROM vaxter"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%\>
\<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%\>
\<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"\>
\<html\>
\<head\>
\<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"\>
\<title\>Untitled Document\</title\>
\<script language="JavaScript" type="text/JavaScript"\>
\<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW \|\| innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//--\>
\</script\>
\</head\>

\<body\>
\<div id="Layer1" style="position:absolute; left:170px; top:40px; width:210px; height:160px; z-index:1"\>\<%=(Recordset1.Fields.Item("Text").Value)%\>\</div\>
\<div id="Layer2" style="position:absolute; left:390px; top:40px; width:180px; height:160px; z-index:2"\>\<%=(Recordset1.Fields.Item("bild").Value)%\>\</div\>

\<% 
While ((Repeat1__numRows \<\> 0) AND (NOT Recordset1.EOF)) 
%\>
\<a href="blomtest2.asp?id=\<%=(Recordset1.Fields.Item("ID").Value)%\>" target="\_self"\>\<%=(Recordset1.Fields.Item("Namn").Value)%\>\</a\>
\<% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
%\>

\</body\>
\</html\>
\<%
Recordset1.Close()
Set Recordset1 = Nothing
%\>

Permalänk: https://www.webforum.nu/p/1508358

## #6 — J.N., 2004-12-17T13:03Z

HEJ!

Nej, det är inte så konstigt.

På blomtest2.asp, då måste du komplettera din SELECT (.source, som du kallar det) med WHERE id=" & request.querystring("id") för att visa just den växten.

Permalänk: https://www.webforum.nu/p/1508423

## #7 — @nders, 2004-12-17T13:05Z

och snälla...

> **J.N. skrev:**
>
> (Använd kod-taggarna också!)

mvh

Permalänk: https://www.webforum.nu/p/1508425

## #8 — Krister, 2004-12-17T16:31Z

Med risk för att bli tjatig titta på <http://www.tradgardsdrommar.se/bildtest5.asp>

Jag få inte bilderna och texten att växla

Här är koden

\<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%\>
\<!--#include file="../Connections/cntrgdrom1.asp" --\>
\<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_cntrgdrom1_STRING
Recordset1.Source = "SELECT ID, Namn, Text, bild FROM vaxter ORDER BY ID ASC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%\>
\<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%\>
\<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"\>
\<html\>
\<head\>
\<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"\>
\<title\>Untitled Document\</title\>
\<script language="JavaScript" type="text/JavaScript"\>
\<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW \|\| innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//--\>
\</script\>
\</head\>

\<body\>
\<div id="Layer1" style="position:absolute; left:170px; top:40px; width:210px; height:160px; z-index:1"\>\<%=(Recordset1.Fields.Item("Text").Value)%\>\</div\>
\<div id="Layer2" style="position:absolute; left:390px; top:40px; width:180px; height:160px; z-index:2"\> \<%=(Recordset1.Fields.Item("bild").Value)%\> \</div\>

\<% While ((Repeat1__numRows \<\> 0) AND (NOT Recordset1.EOF)) 
%\>
\<a href="blomtest5.asp?id=\<%=(Recordset1.Fields.Item("ID").Value)%\>" target="\_self"\>\<%=(Recordset1.Fields.Item("Namn").Value)%\>\</a\>
\<% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
%\>

\</body\>
\</html\>
\<%
Recordset1.Close()
Set Recordset1 = Nothing
%\>

Permalänk: https://www.webforum.nu/p/1508550

## #9 — Krister, 2004-12-17T16:32Z

<Http://www.tradgardsdrommar.se/blomtest5.asp> ska det vara

Permalänk: https://www.webforum.nu/p/1508552

## #10 — J.N., 2004-12-17T16:42Z

HEJ!

Tjata du, men då gör vi det också! :)

> **Krister skrev:**
>
> Jag få inte bilderna och texten att växla

Du måste hämta just DEN posten, <http://www.webforum.nu/showthread.php?s=&postid=969111#post969111>

Om du sedan vill visa BÅDA länkarna ändå, måste du ha två recordset, ett för BÅDA blommorna, en för EXAKT EN, som du får via WHERE i frågan.

Tips: Lägg DW på hyllan, koda för hand först; du får en massa kod som mest tillför oöverskådlighet för en nybörjare.

Bonus I: Man kan redigera inlägg, för stavfel exempelvis.
Bonus II: Kodtaggarna..., <http://www.webforum.nu/showthread.php?s=&postid=468018#post468018.> Tog ett tag för mig att fatta dem också, men du kommer gilla dem. Och VI gör det!

Permalänk: https://www.webforum.nu/p/1508556

## #11 — Krister, 2004-12-17T22:19Z

Tack för hjälpen så långt nu ska jag se om det funkar jag förstår inte riktigt så om du vill skriva ut koden så skulle jag vara tacksam.
Jag lovar att rätta stavfel och använda kodtaggar hädanefter

Permalänk: https://www.webforum.nu/p/1508633

---

Tråden på webben: https://www.webforum.nu/amne/asp/118214-hru-öppnar-man
