Link to home
Start Free TrialLog in
Avatar of MaB
MaBFlag for Sweden

asked on

Can i get a asp generated link to work as an anchor and link to within the same page?

This question starts here:
https://www.experts-exchange.com/questions/20937192/How-to-write-the-SQL-query-in-ASP.html

But since it lead to a question not asked there I'm posting a new.

When using the code in the previous question the link to "B" opens in a new window. Is there any way I can get it to work as a normal anchor and link to a place in the same document. Can I "prerun" the query or something like that?

BR MaB
Avatar of fozylet
fozylet
Flag of India image

<a target="_self" href="<%=anst("anstID")%>">B</a>

If link is to the same page and anst("anstID") is a bookmark then use this...

<a target="_self" href="<%=Request.ServerVariables("SCRIPT_NAME") & "#" & anst("anstID")%>">B</a>
Avatar of MaB

ASKER

Yes the anst("anstID") is a bookmark on the same page so I will try your second tip. I'm using your first tip today and it works like this:

When clicking any of the links (A,B,C,D.....) the first time it opens a new window and navigates to the correct bookmark in that window. In that window I can use the A,B,C... links and it works as I want, moving to the correct bookmark in the same window.

Can you explain this behaviour?

Could you please explain how the Request.ServerVariables("SCRIPT_NAME") works too?
I'm rather new to asp and are eager to learn more.

BR MaB
Avatar of MaB

ASKER

...or exactly I'm using this right now producing the described behaviour:

<a href="#<%=anst("anstID")%>" target="_Self">A</a>

MaB
Avatar of MaB

ASKER

I'm probably doing something wrong, not replacing something that needs to be replaced or so.....
but trying your second tip (Request.ServerVariables....) I get the same result as before.
The first time I click one of the links it opens up a new window and navigates to the correct bookmark in that window. The links then works as desired in the new window but I don't want this new window to open at all.

This however works as I want:

.link            {
            cursor: pointer;
            text-decoration: underline;
            color: blue;
            }

<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')" target="_Self">B</a>

MaB
Avatar of MaB

ASKER

Of course I should be able to remove the target="_Self" from that, just forgot it...
Request.ServerVariables("SCRIPT_NAME") just puts the full path of the page there. How you were doing it originally is just fine too. But can't imagine why would it open in a new window only once and then behave normally!

Are you using frames? Is the base target set to something?
Avatar of MaB

ASKER

I'm not using frames and the base target is set to ..... _New (What the... I was positive I changed that to _Self!).

But that shouldn't matter anyway,  the target inside the a tag should override the base target, shouldn't it?

I will try changing back to the non-javascript now when I've changed the base target back and see what I get as result...
Avatar of MaB

ASKER

....nope, that doesn't work. It still opens in a new window. Back to the javascript....
If you post the full code, i cld try out the same on my end...
Avatar of MaB

ASKER

OK. It's rather much, and under work, and partly in swedish, but here you go:

<%@ Language=VBScript %>
<%response.buffer=true%>
<!--#include file="databas.asp" -->

<%
'öppna connection
Databas.Open strConn
%>
<%response.write("<html><head><title>Kalender</title>")%>
<link rel="stylesheet" type="text/css" href="../../stylesheets/frv.css">
<SCRIPT>
function refreshPeriodic() {
      //Reload the page every 5 minutes
      location.reload();
   timerID = setTimeout("refreshPeriodic()",3000000);
   }
timerID = setTimeout("refreshPeriodic()",3000000);
</SCRIPT>
<script>
window.onload = function ()
{
  //addScrollSynchronization(document.getElementById("div1"), document.getElementById("div3"), "vertical");
  addScrollSynchronization(document.getElementById("div2"), document.getElementById("div3"), "horizontal");
 };
// This is a function that returns a function that is used
// in the event listener
function getOnScrollFunction(oElement)
{
return function () {
if (oElement._scrollSyncDirection == "horizontal" || oElement._scrollSyncDirection == "both")
oElement.scrollLeft = event.srcElement.scrollLeft;
if (oElement._scrollSyncDirection == "vertical" || oElement._scrollSyncDirection == "both")
oElement.scrollTop = event.srcElement.scrollTop;
};

}
// This function adds scroll syncronization for the fromElement to the toElement
// this means that the fromElement will be updated when the toElement is scrolled
function addScrollSynchronization(fromElement, toElement, direction)
{
removeScrollSynchronization(fromElement);

fromElement._syncScroll = getOnScrollFunction(fromElement);
fromElement._scrollSyncDirection = direction;
fromElement._syncTo = toElement;
toElement.attachEvent("onscroll", fromElement._syncScroll);
}

// removes the scroll synchronization for an element
function removeScrollSynchronization(fromElement)
{
if (fromElement._syncTo != null)
fromElement._syncTo.detachEvent("onscroll", fromElement._syncScroll);

fromElement._syncTo = null;;
fromElement._syncScroll = null;
fromElement._scrollSyncDirection = null;
}
</script>
<%
today = Date()
week = DatePart("ww", today,0,0)
dayofyear = DatePart("y", today,0,0)
dayofweek = DatePart("w", today,0,0)
dayno = DatePart("d", today,0,0)
'weekfromdb = DatePart("ww", frv("startdate"),0,0)
'weekfromdb = week
'response.write(weekfromdb & "<br />")
'response.write(week & "<br />")
%>
<base target="_Self">
</head>

<body bgcolor="#FFFFFF" style="border: 1px dotted #CECECE">
<a name="top"></a>
<div class="nav">
<!--<a href="NyFrv.asp">Lägg till frånvaro!</a>-->
<%
searchval = "A"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">A</a>
<%end if%>
<%
searchval = "B"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">B</a>
<%end if%>
<%
searchval = "C"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">C</a>
<%end if%>
<%
searchval = "D"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">D</a>
<%end if%>
<%
searchval = "E"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">E</a>
<%end if%>
<%
searchval = "F"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">F</a>
<%end if%>
<%
searchval = "G"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">G</a>
<%end if%>
<%
searchval = "H"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">H</a>
<%end if%>
<%
searchval = "I"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">I</a>
<%end if%>
<%
searchval = "J"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">J</a>
<%end if%>
<%
searchval = "K"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">K</a>
<%end if%>
<%
searchval = "L"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">L</a>
<%end if%>
<%
searchval = "M"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">M</a>
<%end if%>
<%
searchval = "N"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">N</a>
<%end if%>
<%
searchval = "O"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">O</a>
<%end if%>
<%
searchval = "P"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">P</a>
<%end if%>
<%
searchval = "Q"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">Q</a>
<%end if%>
<%
searchval = "R"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">R</a>
<%end if%>
<%
searchval = "S"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">S</a>
<%end if%>
<%
searchval = "T"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">T</a>
<%end if%>
<%
searchval = "U"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">U</a>
<%end if%>
<%
searchval = "V"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">V</a>
<%end if%>
<%
searchval = "W"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">W</a>
<%end if%>
<%
searchval = "X"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">X</a>
<%end if%>
<%
searchval = "Y"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">Y</a>
<%end if%>
<%
searchval = "Z"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">Z</a>
<%end if%>
<%
searchval = "Å"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">Å</a>
<%end if%>
<%
searchval = "Ä"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">Ä</a>
<%end if%>
<%
searchval = "Ö"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">Ö</a>
<%end if%>
</div>
<div id="div2">
<table border="0" style="border-bottom-style:double; border-bottom-color:#800000; border-collapse:collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">
              <thead>
              <tr height="25" class="lockrow">
                <th style="border-bottom:2px double #800000; border-top-style: solid; border-left-style:solid; border-left-width:1; border-right-style:solid; border-right-width:1; border-top-width:1; " width="150" bgcolor="#CECECE" align="left" valign="top" nowrap><b>&nbsp<%response.write ("Vecka: " & week)%></b></th>
              <th style="border-bottom:2px double #800000; border-top-style: solid; border-right-style: solid; border-left-width:1; border-right-width:1; border-top-width:1" bgcolor="#CECECE" align="left" valign="top" width="150" nowrap>
              <b>&nbsp;Mån</b></th>
              <th style="border-bottom:2px double #800000; border-top-style: solid; border-right-style: solid; border-left-width:1; border-right-width:1; border-top-width:1" bgcolor="#CECECE" align="left" valign="top" width="150" nowrap>
              <b>&nbsp;Tis</b></th>
              <th style="border-bottom:2px double #800000; border-top-style: solid; border-right-style: solid; border-left-width:1; border-right-width:1; border-top-width:1" bgcolor="#CECECE" align="left" valign="top" width="150" nowrap>
              <b>&nbsp;Ons</b></th>
              <th style="border-bottom:2px double #800000; border-top-style: solid; border-right-style: solid; border-left-width:1; border-right-width:1; border-top-width:1" bgcolor="#CECECE" align="left" valign="top" width="150" nowrap>
              <b>&nbsp;Tor</b></th>
              <th style="border-bottom:2px double #800000; border-top-style: solid; border-right-style: solid; border-left-width:1; border-right-width:1; border-top-width:1" bgcolor="#CECECE" align="left" valign="top" width="150" nowrap>
              <b>&nbsp;Fre</b></th>
              </tr>
              </thead>
              </table>
              </div>
              <div id="div3">
                    <table cellspacing="0" cellpadding="5" border="0" style="border-collapse: collapse" bordercolor="#111111">
              <tbody>
              <%

                    'SQLstr = "SELECT * FROM Frvtid"
                    'set frv = Databas.execute(SQLstr)

                    SQLstr = "SELECT * FROM Anst order by enamn"
                    set anst = Databas.execute(SQLstr)

                    %>
                    <%Do Until anst.EOF%>
                    <tr id="<%=anst("anstID")%>">
              <td style="border-style:solid; border-width: 1" align="left" valign="top" width="150" height="45" nowrap><span style="text-transform: capitalize; color: #800000">&nbsp;<b><%=anst("enamn")%>&nbsp;<%=anst("fnamn")%></b><br /><%if anst("mail") <> "" then%>&nbsp;<a class="mail" href="mailto:<%=anst("mail")%>">e-mail</a><%end if%><br /><%if anst("tel") <> "" then%>&nbsp;<%=anst("tel")%><br /><%end if%><%if anst("mobtel") <> "" then%>&nbsp;<%=anst("mobtel")%><br /><%end if%></td>
              <td style="border-style:solid; border-width: 1" bgcolor="#FFFFCC" align="left" valign="top" width="150" height="45" bordercolorlight="#808080" bordercolordark="#111111" bordercolor="#111111" nowrap>
              <em>
              <%SQLstr = "SELECT * FROM Frvtid"
                     set frv = Databas.execute(SQLstr)%>
                    <%Do Until frv.EOF%>
              <%weekfromdb = DatePart("ww", frv("startdate"),0,0)%>
              <%dayfromdb = DatePart("w", frv("startdate"),0,0)%>
                    <%if anst("anstID") = frv("anstID") and weekfromdb = week and dayfromdb = 1 then%><%=Right("00" & CStr(DatePart("h", frv("starttime"))),2)%>:<%=Right("00" & CStr(DatePart("n", frv("starttime"))),2)%>-<%=Right("00" & CStr(DatePart("h", frv("endtime"))),2)%>:<%=Right("00" & Cstr(DatePart("n", frv("endtime"))),2)%></em>&nbsp;<%=frv("description")%><%end if%>
              <%
              frv.MoveNext
              loop
              %>&nbsp;</td>
              <td style="border-style:solid; border-width: 1" align="left" valign="top" width="150" height="45" bordercolorlight="#808080" bordercolordark="#111111" bordercolor="#111111" nowrap>
              <em>
              <%SQLstr = "SELECT * FROM Frvtid"
                     set frv = Databas.execute(SQLstr)%>
                    <%Do Until frv.EOF%>
              <%weekfromdb = DatePart("ww", frv("startdate"),0,0)%>
              <%dayfromdb = DatePart("w", frv("startdate"),0,0)%>
              <%if anst("anstID") = frv("anstID") and weekfromdb = week and dayfromdb = 2 then%><%=Right("00" & CStr(DatePart("h", frv("starttime"))),2)%>:<%=Right("00" & CStr(DatePart("n", frv("starttime"))),2)%>-<%=Right("00" & CStr(DatePart("h", frv("endtime"))),2)%>:<%=Right("00" & Cstr(DatePart("n", frv("endtime"))),2)%></em>&nbsp;<%=frv("description")%><%end if%>
              <%
              frv.MoveNext
              loop
              %>&nbsp;</td>
              <td style="border-style:solid; border-width: 1" bgcolor="#FFFFCC" align="left" valign="top" width="150" height="45" bordercolorlight="#808080" bordercolordark="#111111" bordercolor="#111111" nowrap>
              <em>
              <%SQLstr = "SELECT * FROM Frvtid"
                     set frv = Databas.execute(SQLstr)%>
                    <%Do Until frv.EOF%>
              <%weekfromdb = DatePart("ww", frv("startdate"),0,0)%>
              <%dayfromdb = DatePart("w", frv("startdate"),0,0)%>
                    <%if anst("anstID") = frv("anstID") and weekfromdb = week and dayfromdb = 3 then%><%=Right("00" & CStr(DatePart("h", frv("starttime"))),2)%>:<%=Right("00" & CStr(DatePart("n", frv("starttime"))),2)%>-<%=Right("00" & CStr(DatePart("h", frv("endtime"))),2)%>:<%=Right("00" & Cstr(DatePart("n", frv("endtime"))),2)%></em>&nbsp;<%=frv("description")%><%end if%>
              <%
              frv.MoveNext
              loop
              %>&nbsp;</td>
              <td style="border-style:solid; border-width: 1" align="left" valign="top" width="150" height="45" bordercolorlight="#808080" bordercolordark="#111111" bordercolor="#111111" nowrap>
              <em>
              <%SQLstr = "SELECT * FROM Frvtid"
                     set frv = Databas.execute(SQLstr)%>
                    <%Do Until frv.EOF%>
              <%weekfromdb = DatePart("ww", frv("startdate"),0,0)%>
              <%dayfromdb = DatePart("w", frv("startdate"),0,0)%>
                    <%if anst("anstID") = frv("anstID") and weekfromdb = week and dayfromdb = 4 then%><%=Right("00" & CStr(DatePart("h", frv("starttime"))),2)%>:<%=Right("00" & CStr(DatePart("n", frv("starttime"))),2)%>-<%=Right("00" & CStr(DatePart("h", frv("endtime"))),2)%>:<%=Right("00" & Cstr(DatePart("n", frv("endtime"))),2)%></em>&nbsp;<%=frv("description")%><%end if%>
              <%
              frv.MoveNext
              loop
              %>&nbsp;</td>
              <td style="border-style:solid; border-width: 1" bgcolor="#FFFFCC" align="left" valign="top" width="150" height="45" bordercolorlight="#808080" bordercolordark="#111111" bordercolor="#111111" nowrap>
              <em>
              <%SQLstr = "SELECT * FROM Frvtid"
                     set frv = Databas.execute(SQLstr)%>
                    <%Do Until frv.EOF%>
              <%weekfromdb = DatePart("ww", frv("startdate"),0,0)%>
              <%dayfromdb = DatePart("w", frv("startdate"),0,0)%>
                    <%if anst("anstID") = frv("anstID") and weekfromdb = week and dayfromdb = 5 then%><%=Right("00" & CStr(DatePart("h", frv("starttime"))),2)%>:<%=Right("00" & CStr(DatePart("n", frv("starttime"))),2)%>-<%=Right("00" & CStr(DatePart("h", frv("endtime"))),2)%>:<%=Right("00" & Cstr(DatePart("n", frv("endtime"))),2)%></em>&nbsp;<%=frv("description")%><%end if%>
              <%
              frv.MoveNext
              loop
              %>&nbsp;</td>
              </tr>
               <%
               anst.MoveNext
               loop
               %>
               </tbody>
</table>
</div>                  
<%
'Rensa upp
frv.close
anst.close
Databas.close
set databas = Nothing
%></body></html>
Avatar of MaB

ASKER

...and I'm playing around with an alternate layout too.......

<%@ Language=VBScript %>
<%response.buffer=true%>
<!--#include file="databas.asp" -->

<%
'öppna connection
Databas.Open strConn
%>
<%response.write("<html><head><title>Kalender</title>")%>
<link rel="stylesheet" type="text/css" href="../../stylesheets/frv.css">
<SCRIPT>
function refreshPeriodic() {
      //Reload the page every 5 minutes
      location.reload();
   timerID = setTimeout("refreshPeriodic()",3000000);
   }
timerID = setTimeout("refreshPeriodic()",3000000);
</SCRIPT>
<script>
window.onload = function ()
{
  addScrollSynchronization(document.getElementById("div1"), document.getElementById("div3"), "vertical");
  addScrollSynchronization(document.getElementById("div2"), document.getElementById("div3"), "horizontal");
 };
// This is a function that returns a function that is used
// in the event listener
function getOnScrollFunction(oElement)
{
return function () {
if (oElement._scrollSyncDirection == "horizontal" || oElement._scrollSyncDirection == "both")
oElement.scrollLeft = event.srcElement.scrollLeft;
if (oElement._scrollSyncDirection == "vertical" || oElement._scrollSyncDirection == "both")
oElement.scrollTop = event.srcElement.scrollTop;
};

}
// This function adds scroll syncronization for the fromElement to the toElement
// this means that the fromElement will be updated when the toElement is scrolled
function addScrollSynchronization(fromElement, toElement, direction)
{
removeScrollSynchronization(fromElement);

fromElement._syncScroll = getOnScrollFunction(fromElement);
fromElement._scrollSyncDirection = direction;
fromElement._syncTo = toElement;
toElement.attachEvent("onscroll", fromElement._syncScroll);
}

// removes the scroll synchronization for an element
function removeScrollSynchronization(fromElement)
{
if (fromElement._syncTo != null)
fromElement._syncTo.detachEvent("onscroll", fromElement._syncScroll);

fromElement._syncTo = null;;
fromElement._syncScroll = null;
fromElement._scrollSyncDirection = null;
}
</script>
<%
today = Date()
week = DatePart("ww", today,0,0)
dayofyear = DatePart("y", today,0,0)
dayofweek = DatePart("w", today,0,0)
dayno = DatePart("d", today,0,0)
'weekfromdb = DatePart("ww", frv("startdate"),0,0)
'weekfromdb = week
'response.write(weekfromdb & "<br />")
'response.write(week & "<br />")
%>
<base target="_Self">
</head>

<body bgcolor="#FFFFFF" style="border: 1px dotted #CECECE">
<a name="top" class="link" onClick="self.location.href('#fri')">Fredag</a>
<div class="nav">
<!--<a href="NyFrv.asp">Lägg till frånvaro!</a>-->
<%
searchval = "A"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">A</a>
<%end if%>
<%
searchval = "B"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">B</a>
<%end if%>
<%
searchval = "C"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">C</a>
<%end if%>
<%
searchval = "D"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">D</a>
<%end if%>
<%
searchval = "E"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">E</a>
<%end if%>
<%
searchval = "F"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">F</a>
<%end if%>
<%
searchval = "G"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">G</a>
<%end if%>
<%
searchval = "H"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">H</a>
<%end if%>
<%
searchval = "I"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">I</a>
<%end if%>
<%
searchval = "J"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">J</a>
<%end if%>
<%
searchval = "K"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">K</a>
<%end if%>
<%
searchval = "L"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">L</a>
<%end if%>
<%
searchval = "M"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">M</a>
<%end if%>
<%
searchval = "N"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">N</a>
<%end if%>
<%
searchval = "O"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">O</a>
<%end if%>
<%
searchval = "P"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">P</a>
<%end if%>
<%
searchval = "Q"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">Q</a>
<%end if%>
<%
searchval = "R"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">R</a>
<%end if%>
<%
searchval = "S"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">S</a>
<%end if%>
<%
searchval = "T"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">T</a>
<%end if%>
<%
searchval = "U"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">U</a>
<%end if%>
<%
searchval = "V"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">V</a>
<%end if%>
<%
searchval = "W"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">W</a>
<%end if%>
<%
searchval = "X"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">X</a>
<%end if%>
<%
searchval = "Y"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">Y</a>
<%end if%>
<%
searchval = "Z"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">Z</a>
<%end if%>
<%
searchval = "Å"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">Å</a>
<%end if%>
<%
searchval = "Ä"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">Ä</a>
<%end if%>
<%
searchval = "Ö"
SQLstr = "SELECT anstID, enamn FROM Anst WHERE enamn LIKE '" &  searchval & "%'"
set anst = Databas.execute(SQLstr)
if not(anst.eof and anst.bof) then
%>
<a class="link" onClick="self.location.href('#<%=anst("anstID")%>')">Ö</a>
<%end if%>
</div>
<table width="90%">
<tr>
<td align="left" valign="top">
<table border="0" style="border-bottom-style:double; border-bottom-color:#800000; border-collapse:collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">
<thead>
<tr height="25">
<th style="border-bottom:2px double #800000; border-top-style: solid; border-left-style:solid; border-left-width:1; border-right-style:solid; border-right-width:1; border-top-width:1; " width="150" bgcolor="#CECECE" align="left" valign="top" nowrap><b>&nbsp<%response.write ("Vecka: " & week)%></b></th>
</tr>
</table>
</td>
<td align="left" valign="top">
              <div id="div2">
                    <table border="0" style="border-bottom-style:double; border-bottom-color:#800000; border-collapse:collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">
              <tr height="25">
              <th style="border-bottom:2px double #800000; border-top-style: solid; border-right-style: solid; border-left-width:1; border-right-width:1; border-top-width:1; border-left-style:solid" bgcolor="#CECECE" align="left" valign="top" width="300" nowrap>
              <b>&nbsp;Mån</b></th>
              <th style="border-bottom:2px double #800000; border-top-style: solid; border-right-style: solid; border-left-width:1; border-right-width:1; border-top-width:1" bgcolor="#CECECE" align="left" valign="top" width="300" nowrap>
              <b>&nbsp;Tis</b></th>
              <th style="border-bottom:2px double #800000; border-top-style: solid; border-right-style: solid; border-left-width:1; border-right-width:1; border-top-width:1" bgcolor="#CECECE" align="left" valign="top" width="300" nowrap>
              <b>&nbsp;Ons</b></th>
              <th style="border-bottom:2px double #800000; border-top-style: solid; border-right-style: solid; border-left-width:1; border-right-width:1; border-top-width:1" bgcolor="#CECECE" align="left" valign="top" width="300" nowrap>
              <b>&nbsp;Tor</b></th>
              <th style="border-bottom:2px double #800000; border-top-style: solid; border-right-style: solid; border-left-width:1; border-right-width:1; border-top-width:1" bgcolor="#CECECE" align="left" valign="top" width="300" nowrap>
              <b>&nbsp;Fre</b></th>
              </tr>
              </thead>
              </table>
              </div>
              </td>
              </tr>
              <tbody>
              <td align="left" valign="top">
              <div id="div1">
              <table cellspacing="0" cellpadding="5" border="0" style="border-collapse: collapse" bordercolor="#111111">
              <%
                    SQLstr = "SELECT * FROM Anst order by enamn"
                    set anstfirst = Databas.execute(SQLstr)
                    %>
                    <%Do Until anstfirst.EOF%>
                    <tr>
              <td style="border-style:solid; border-width: 1" align="left" valign="top" width="150" height="60" nowrap><span style="text-transform: capitalize; color: #800000">&nbsp;<b><%=anstfirst("enamn")%>&nbsp;<%=anstfirst("fnamn")%></b><br /><%if anstfirst("mail") <> "" then%>&nbsp;<a class="mail" href="mailto:<%=anstfirst("mail")%>">e-mail</a><%end if%><br /><%if anstfirst("tel") <> "" then%>&nbsp;<%=anstfirst("tel")%><br /><%end if%><%if anstfirst("mobtel") <> "" then%>&nbsp;<%=anstfirst("mobtel")%><br /><%end if%></td>
              </tr>
              <%
              anstfirst.MoveNext
              loop
              %>
              </table>
              </div>
              </td>
              <td align="left" valign="top">
              <div id="div3">
                    <table cellspacing="0" cellpadding="5" border="0" style="border-collapse: collapse" bordercolor="#111111">
              <%

                    'SQLstr = "SELECT * FROM Frvtid"
                    'set frv = Databas.execute(SQLstr)

                    SQLstr = "SELECT * FROM Anst order by enamn"
                    set anst = Databas.execute(SQLstr)

                    %>
                    <%Do Until anst.EOF%>
                    <tr id="<%=anst("anstID")%>">
              <td style="border-style:solid; border-width: 1" bgcolor="#FFFFCC" align="left" valign="top" width="300" height="60" bordercolorlight="#808080" bordercolordark="#111111" bordercolor="#111111" nowrap>
              <a name="mon"></a>
              <em>
              <%SQLstr = "SELECT * FROM Frvtid"
                     set frv = Databas.execute(SQLstr)%>
                    <%Do Until frv.EOF%>
              <%weekfromdb = DatePart("ww", frv("startdate"),0,0)%>
              <%dayfromdb = DatePart("w", frv("startdate"),0,0)%>
                    <%if anst("anstID") = frv("anstID") and weekfromdb = week and dayfromdb = 1 then%><%=Right("00" & CStr(DatePart("h", frv("starttime"))),2)%>:<%=Right("00" & CStr(DatePart("n", frv("starttime"))),2)%>-<%=Right("00" & CStr(DatePart("h", frv("endtime"))),2)%>:<%=Right("00" & Cstr(DatePart("n", frv("endtime"))),2)%></em>&nbsp;<%=frv("description")%><%end if%>
              <%
              frv.MoveNext
              loop
              %>&nbsp;</td>
              <td style="border-style:solid; border-width: 1" align="left" valign="top" width="300" height="60" bordercolorlight="#808080" bordercolordark="#111111" bordercolor="#111111" nowrap>
              <a name="tue"></a>
              <em>
              <%SQLstr = "SELECT * FROM Frvtid"
                     set frv = Databas.execute(SQLstr)%>
                    <%Do Until frv.EOF%>
              <%weekfromdb = DatePart("ww", frv("startdate"),0,0)%>
              <%dayfromdb = DatePart("w", frv("startdate"),0,0)%>
              <%if anst("anstID") = frv("anstID") and weekfromdb = week and dayfromdb = 2 then%><%=Right("00" & CStr(DatePart("h", frv("starttime"))),2)%>:<%=Right("00" & CStr(DatePart("n", frv("starttime"))),2)%>-<%=Right("00" & CStr(DatePart("h", frv("endtime"))),2)%>:<%=Right("00" & Cstr(DatePart("n", frv("endtime"))),2)%></em>&nbsp;<%=frv("description")%><%end if%>
              <%
              frv.MoveNext
              loop
              %>&nbsp;</td>
              <td style="border-style:solid; border-width: 1" bgcolor="#FFFFCC" align="left" valign="top" width="300" height="60" bordercolorlight="#808080" bordercolordark="#111111" bordercolor="#111111" nowrap>
              <a name="wed"></a>
              <em>
              <%SQLstr = "SELECT * FROM Frvtid"
                     set frv = Databas.execute(SQLstr)%>
                    <%Do Until frv.EOF%>
              <%weekfromdb = DatePart("ww", frv("startdate"),0,0)%>
              <%dayfromdb = DatePart("w", frv("startdate"),0,0)%>
                    <%if anst("anstID") = frv("anstID") and weekfromdb = week and dayfromdb = 3 then%><%=Right("00" & CStr(DatePart("h", frv("starttime"))),2)%>:<%=Right("00" & CStr(DatePart("n", frv("starttime"))),2)%>-<%=Right("00" & CStr(DatePart("h", frv("endtime"))),2)%>:<%=Right("00" & Cstr(DatePart("n", frv("endtime"))),2)%></em>&nbsp;<%=frv("description")%><%end if%>
              <%
              frv.MoveNext
              loop
              %>&nbsp;</td>
              <td style="border-style:solid; border-width: 1" align="left" valign="top" width="300" height="60" bordercolorlight="#808080" bordercolordark="#111111" bordercolor="#111111" nowrap>
              <a name="thu"></a>
              <em>
              <%SQLstr = "SELECT * FROM Frvtid"
                     set frv = Databas.execute(SQLstr)%>
                    <%Do Until frv.EOF%>
              <%weekfromdb = DatePart("ww", frv("startdate"),0,0)%>
              <%dayfromdb = DatePart("w", frv("startdate"),0,0)%>
                    <%if anst("anstID") = frv("anstID") and weekfromdb = week and dayfromdb = 4 then%><%=Right("00" & CStr(DatePart("h", frv("starttime"))),2)%>:<%=Right("00" & CStr(DatePart("n", frv("starttime"))),2)%>-<%=Right("00" & CStr(DatePart("h", frv("endtime"))),2)%>:<%=Right("00" & Cstr(DatePart("n", frv("endtime"))),2)%></em>&nbsp;<%=frv("description")%><%end if%>
              <%
              frv.MoveNext
              loop
              %>&nbsp;</td>
              <td style="border-style:solid; border-width: 1" bgcolor="#FFFFCC" align="left" valign="top" width="300" height="60" bordercolorlight="#808080" bordercolordark="#111111" bordercolor="#111111" nowrap>
              <a name="fri"></a>
              <em>
              <%SQLstr = "SELECT * FROM Frvtid"
                     set frv = Databas.execute(SQLstr)%>
                    <%Do Until frv.EOF%>
              <%weekfromdb = DatePart("ww", frv("startdate"),0,0)%>
              <%dayfromdb = DatePart("w", frv("startdate"),0,0)%>
                    <%if anst("anstID") = frv("anstID") and weekfromdb = week and dayfromdb = 5 then%><%=Right("00" & CStr(DatePart("h", frv("starttime"))),2)%>:<%=Right("00" & CStr(DatePart("n", frv("starttime"))),2)%>-<%=Right("00" & CStr(DatePart("h", frv("endtime"))),2)%>:<%=Right("00" & Cstr(DatePart("n", frv("endtime"))),2)%></em>&nbsp;<%=frv("description")%><%end if%>
              <%
              frv.MoveNext
              loop
              %>&nbsp;</td>
              </tr>
               <%
               anst.MoveNext
               loop
               %>
               </tbody>
</table>
</div>                  
</td>
</tr>
</table>
<%
'Rensa upp
frv.close
anstfirst.close
anst.close
Databas.close
set databas = Nothing
%></body></html>
Avatar of MaB

ASKER

....and this is the stylesheet

.nav            {
                  position: relative;
                  top: 0px;
                  left: 0px;
                  height: 30;
                  width: 100%;
                  font-family:Verdana;
                  font-size:0.8em;
                  color:#800000;
                  text-decoration:none;
                  font-weight:bold;
                  text-align:center
                  }

.mail             {
                  text-transform: lowercase;
                  }
                  
.lockrow      {
                  position:relative;
                  top:expression(this.offsetParent.scrollTop);
                  }

.link            {
                  cursor: pointer;
                  text-decoration: underline;
                  color: blue;
                  }

#div1             {
                    overflow: hidden;
                    height: 308;
                    width: 150;
                    }

#div2             {
                    overflow: hidden;
                    width: 600;
                  }

#div3            {
                    overflow: auto;
                    width: 600;
                  height: 320;
                  border-bottom-style:double;
                  border-bottom-width:3;
                  }

BODY             {
                  font-family:Verdana;
                  font-size:10px;
                  color:#000033;
                  background-color:#ffffff;
                  scrollbar-base-color: #ebebeb;
                    scrollbar-face-color: #dfdfdf;
                    scrollbar-track-color: #ffffff;
                    scrollbar-arrow-color: #800000;
                    scrollbar-highlight-color: #efefef;
                    scrollbar-3dlight-color: #0C0C0C;
                    scrollbar-shadow-color: #000000;
                    scrollbar-darkshadow-color: #ffffff;
                  overflow: hidden;
                  }

th                   {
                  font-family:Verdana;
                  font-size:10px;
                  color:#000033;
                  }

td                   {
                  font-family:Verdana;
                  font-size:10px;
                  color:#000033;
                  }

a                  {
                  font-family: Verdana;
                  font-style: normal;
                  font-size: 10px;
                  }


a      em            {
                  font-family: Verdana;
                  font-style: normal;
                  font-size: 10px;
                  }

td em            {
                  color: #000033;
                  font-family: Verdana;
                  font-size: 10px;
                  font-style: italic;
                  }
                   
H1                  {
                  font-family:Verdana;
                  font-size:12pt;
                  color:#800000;
                  font-weight:bold;
                  font-style: normal;
                  }                  
p                  {
                  color: #000033;
                  font-family: Verdana;
                  font-size: 10px;
                  font-weight: bold
                 }
ASKER CERTIFIED SOLUTION
Avatar of GhostMod
GhostMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial