Avatar billede bramstorp Nybegynder
01. december 2006 - 16:44 Der er 3 kommentarer og
1 løsning

Hjælp til at skifte dag

Jeg har downloadet en kalender på nettet, men jeg kan ikke skifte ugedagen fra sunday to Saturday, jeg vil gerne have monday to sunday. er der nogle der kan hjælpe.

<!--#include file="config.asp" -->
<%
dim objRs, objCon, dtToday

' open the database
set objCon= Server.CreateObject("ADODB.Connection")
objCon.Open strCon

cat = Request.QueryString("cat")
if cat = "" then
    cat = "all"
End If

'Write a select box
Sub DropDown(tbl, valField, selVal, Field)
    set rsDrop = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT DISTINCT " & valField & ", " & Field & " FROM " & tbl & _
        " ORDER BY " & field
    rsDrop.Open strSQL, objCon
    Response.Write "<option value=1>Select...</option>"
    do until rsDrop.EOF
        Response.Write "<option value='"
        Response.Write rsDrop(valfield) & "'"
        Response.Write ">"  & rsDrop(field) & "</option>" & vbcrlf
        rsDrop.MoveNext
    loop
    rsDrop.Close
    set rsDrop=nothing
end sub

' Format the ouput
Function FormatStr(String)
    on Error resume next
    String = Replace(String, CHR(13), "")
    String = Replace(String, CHR(10) & CHR(10), "</P><P>")
    String = Replace(String, CHR(10), "<BR>")
    FormatStr = String
End Function

function dNum(n)
    if n >= 10 then
        dNum = cstr(n)
    Else
        dNum = "0" & cstr(n)
    End If
End Function

'SQL Formatted Date
Function SQLDate(dt)
    SQLDate = cdbl(dt) ' Year(dt) & "-" & DNum(Month(dt))  & "-" &  Dnum(Day(dt)) & " " &  dnum(hour(dt)) & ":" & dnum(Minute(dt))
End Function

' Get the previous sunday date
Function DtPrevSunday(ByVal dt)
    Do While WeekDay(dt) > vbSunday
        dt = DateAdd("d", -1, dt)
    Loop
    DtPrevSunday = dt
End Function

'Todays Date 
dtToday = Date()

Dim dtCurViewMonth ' First day of the currently viewed month
Dim dtCurViewDay ' Current day of the currently viewed month
Dim frmDate ' Date submitted by form

' if the GO button was used, build the date from the month and year
If InStr(1, Request.Form, "subGO", 1) > 0  then
    if Request.Form("CURDATE_month") = "" then
        tmpMonth = month(now())
    else
        tmpMonth = Request.Form("CURDATE_month")
    End If
   
    if Request.Form("CURDATE_year") = "" then
        tmpyear = year(now())
    else
        tmpyear = Request.Form("CURDATE_year")
    End If
       
    tmpDate = "1 " & tmpMonth & " 1999"
   
    mnth = Month(tmpDate)
    frmDate = DateSerial(tmpyear, mnth, 1)
Else
    frmDate = Request.Form("CURDATE")   
end if


if Request("view_date") <> "" then
    frmDate= DateSerial(year(Request("view_date")), month(Request("view_date")), 1)
end if


' if posted from the form
' if prev button was hit on the form
  If InStr(1, Request.Form, "subPrev", 1) > 0 Then
      dtCurViewMonth = DateAdd("m", -1, frmDate)
' if next button was hit on the form
  ElseIf InStr(1, Request.Form, "subNext", 1) > 0 Then
      dtCurViewMonth = DateAdd("m", 1, frmDate)
' anyother time
      Else
' date add in text box
        If InStr(1, Request.Form, "subGO", 1) > 0 then
            dtCurViewMonth = frmDate
        Else
            if Request("view_date") <> "" then
                dtCurviewMonth = frmDate
            else
            dtCurViewMonth = DateSerial(Year(dtToday), Month(dtToday), 1)
            End If
        End If
  End If


Dim iDay, iWeek, sFontColor, dictDte(31,2), intCount 
strSQL ="SELECT cal.id, cal.dte, cal.text_field, cal_Categorys.Category, cal_Categorys.Colour, cal_Categorys.BgColour" & _
        " FROM cal_Categorys RIGHT JOIN cal ON cal_Categorys.Cat_ID = cal.Category " & _
        " WHERE month(cal.dte)= " & month(dtCurViewMonth) & " and year(cal.dte) = " & year(dtCurViewMonth)
       
if cat <> "all" then
    strSQL = strSQL & " AND  cal_Categorys.Cat_ID = " & cat
End If
strSQL = strSQL & "  order by cal.dte"
 
set objRs = objCon.Execute (StrSql)
intCount= 0
 
' populate array with days of month 
tmpDay = ""
 
do until objRs.EOF 
    if day(objRs("dte"))  = tmpDay then
            lnk = "<a href=cal_view.asp?id=" & objRs("id") & " style='color:" & objRs("colour") & _
                "; background:" & objRs("BgColour") & ";" & "font-family:verdana;font-size:8pt;line-height:15px' title='" & cdate(objRs("dte"))  & "'>"  &_
                objRs("text_field") & "</a>"
               
            dictDte(intCount-1, 1) = dictDte(intCount-1, 1) & "<br>" & lnk
              tmpDay = day(objRs("dte"))
            objRs.Movenext
    Else       
        if Day(objRs("dte")) = intCount + 1 then
            lnk = "<a href=cal_view.asp?id=" & objRs("id") & " style='color:" & objRs("colour") & _
                "; background-color:" & objRs("BgColour") & ";" & "font-family:verdana;font-size:8pt;line-height:15px' title='" & cdate(objRs("dte"))  & "'>"  &_
                objRs("text_field") & "</a>"
            dictDte(intCount, 1) = lnk
            tmpDay = day(objRs("dte"))
            objRs.Movenext
            intCount = intCount + 1
        Else
            dictDte(intCount, 1) = " "
            intCount = intCount + 1
        End If           
        dictDte(intCount, 2) = intCount + 1       
    End if
loop
%>
<html>
<head>
<META NAME="GENERATOR" Content="PFE 32-bit Edition ver. 1.01">
<META NAME="ROBOTS" CONTENT="INDEX,NOFOLLOW">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-store">

<script language="javascript">

</script>
<link rel="stylesheet" type="text/css" href="bs.css">
<title>test</title></head>
<body>
<form name="fmNextPrev" action="default.asp?cat=<%=cat%>" method="post">
<table cellpadding="3" cellspacing="1" width="600" border="0" align="center">
    <tr valign="middle">
        <td><a href="default.asp"> [ <%= Today %></a> ][ <a href="cal_manager.asp"><%= login %> ] </a></td>
       
    </tr>
</table>
<table cellpadding="3" cellspacing="1" width="600" border="0" class="maintble" align="center">
    <tr valign="middle" align="center">
        <td colspan="7" class="Item">   
            <table cellpadding="0" cellspacing="0" width="100%" border="0">
                <tr valign="middle" align="center">
                  <td width="30%" align="right">
                    <input name="subPrev" type="image" src="images/left_icon.gif" width="45" height="25">
                 
                  </td>
                  <td width="40%" class="heading2">
                      <%=cal_name%>
                  </td>
                  <td width="30%" align="left">
                    <input type="image" name="subNext" src="images/Right_icon.gif" width="45" height="25">                  </td>
                </tr>
          </table>
      </td>
    </tr>
    <tr valign="top">
        <!-- Start Day of the calendar can be change here  -->
          <% For iDay = vbSunday To vbSaturday %>
            <td width="14%" class="titlebar"><%=WeekDayName(iDay)%></td>
          <%Next %>
    </tr>

<%
dtCurViewDay = DtPrevSunday(dtCurViewMonth)

For iWeek = 0 To 5
    Response.Write "<tr valign=top>" & vbCrLf
    For iDay = vbSunday To vbSaturday
        sBGCOLOR = "cell"
        If Month(dtCurViewDay) = Month(dtCurViewMonth) Then
            If dtCurViewDay = dtToday Then sBGCOLOR = "cellToday"
        else
            sBGCOLOR = "cell"
        End If

        Response.Write "<td height=50 class='" & sBGCOLOR & "'>"       
     
        If Month(dtCurViewDay) = Month(dtCurViewMonth) Then
            if Session("CalAdmin") then
                Response.Write "<a href=cal_manager.asp?cat=" & cat & "&" & "view_date=" & SQLDate(dtCurViewday) & ">"
                Response.Write  Day(dtCurViewDay) & "</a></B><br>"
            Else
                Response.Write  Day(dtCurViewDay) & "</B><br>"            
            End If
            Response.Write  formatStr(dictDte(Day(dtCurViewDay)- 1, 1)) & "<BR>"
        End If

        Response.Write "</td>" & vbCrLf
        dtCurViewDay = DateAdd("d", 1, dtCurViewDay)
      Next
      Response.Write "</tr>" & vbCrLf
  Next

%>
</table>
<center>
<table cellpadding="3" cellspacing="1" width="600" border="0" class="maintble" align="center">

  <tr>
    <td align="center" valign="middle" class="main2"><span class="main3"><%=MonthName(Month(dtCurViewMonth)) & " " & Year(dtCurViewMonth)%></span></td>
    </tr>
</table>


<div align="center">
<input type="hidden" Name="CURDATE" Value="<%=dtCurViewMonth%>">
</form>
</font>
</body>
</html>
<%
on error resume next
objRs.close
objCon.Close
set objrs = nothing
set objCon=nothing
%>
Avatar billede keenkbh Nybegynder
03. december 2006 - 16:25 #1
Har du prøvet at ændre den her linje:

For iDay = vbSunday To vbSaturday

til:

For iDay = vbMonday To vbSonday

???
Avatar billede bramstorp Nybegynder
03. december 2006 - 16:59 #2
Ja men så forsvinder linien med ugedagene
Avatar billede johnstigers Seniormester
15. august 2008 - 20:20 #3
Lukketid...
Avatar billede bramstorp Nybegynder
16. august 2008 - 19:55 #4
luk
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester