Tjena !! Du har en textruta som heter txtStartCalender gord för aspsida?
har någon sett eller gort en calender som man kan använda
för att klicka fram ett datum dag/mån/år i (ex:vbscrips/asp)
tja
TobbeSv: Calender gord för aspsida?
-----------------------------------------
Sub txtStart_onclick
strRetur=showModalDialog("../../../datum/datum.htm","","dialogLeft=150;dialogTop=150;dialogWidth=310pt;dialogHeight=190pt")
if strRetur="" then exit sub
if mid(strRetur,1,1)="u" then
MsgBox "Du måste välja datum eller klicka på avbryt",vbInformation
exit sub
end if
-----------------------------------------------------------
När du klickar i textrutan anropas nedanstående script som öppanr
en dialogbox, när du valt datum (klickat) returneras värdet till textrutan
------------------------------------------------------------
<%
response.expires = 0
%>
<HTML>
<HEAD>
<TITLE>Välj datum</TITLE>
<style>
BODY
{
BACKGROUND-COLOR: gainsboro
}
.today
{
BACKGROUND-COLOR: transparent;
BORDER-BOTTOM: ridge;
BORDER-LEFT: ridge;
BORDER-RIGHT: ridge;
BORDER-TOP: ridge;
COLOR: blue;
FONT-FAMILY: Verdana;
FONT-SIZE: 9pt
}
TD
{
FONT-FAMILY: Verdana;
FONT-SIZE: 8pt
}
#val
{
COLOR: mediumblue;
FONT-FAMILY: Verdana;
FONT-SIZE: 8pt
}
#knapp
{
COLOR: black;
FONT-FAMILY: Verdana;
FONT-SIZE: 8pt;
FONT-WEIGHT: 500
}
.dagar
{
COLOR: darkblue;
FONT-FAMILY: Verdana;
FONT-WEIGHT: bold
}
</style>
<SCRIPT LANGUAGE="JavaScript">
// Initialize arrays.
var maanad = new Array("Januari", "Februari", "Mars",
"April", "Maj", "Juni", "Juli", "Augusti", "September",
"Oktober", "November", "December");
var dagIMaanad = new Array(31, 28, 31, 30, 31, 30, 31, 31,
30, 31, 30, 31);
var dagar = new Array("Måndag", "Tisdag",
"Onsdag", "Torsdag", "Fredag","Lördag","Söndag");
function getdagar(month, year) {
// Test for leap year when February is selected.
if (1 == month)
return ((0 == year % 4) && (0 != (year % 100))) ||
(0 == year % 400) ? 29 : 28;
else
return dagIMaanad[month];
}
function getIdag() {
// Generate today's date.
this.now = new Date();
this.year = this.now.getFullYear();
this.month = this.now.getMonth();
this.day = this.now.getDate();
}
// Start with a calendar for today.
today = new getIdag();
function newCalendar() {
today = new getIdag();
var parseYear = parseInt(document.all.year
[document.all.year.selectedIndex].text);
var newCal = new Date(parseYear,
document.all.month.selectedIndex, 1);
var day = -1;
var startDay = newCal.getDay()-1;
var daily = 0;
if ((today.year == newCal.getFullYear()) &&
(today.month == newCal.getMonth()))
day = today.day;
// Cache the calendar table's tBody section, dayList.
var tableCal = document.all.calendar.tBodies.dayList;
var intdagIMaanad =
getdagar(newCal.getMonth(), newCal.getFullYear());
for (var intWeek = 0; intWeek < tableCal.rows.length;intWeek++)
for (var intDay = 0;intDay < tableCal.rows[intWeek].cells.length;intDay++) {
var cell = tableCal.rows[intWeek].cells[intDay];
// Start counting dagar.
if ((intDay == startDay) && (0 == daily))
daily = 1;
// Highlight the current day.
cell.className = (day == daily) ? "today" : "";
// Output the day number into the cell.
if ((-1 == startDay) && (daily <= intdagIMaanad))
{
cell = tableCal.rows[0].cells[0];
cell.innerText = "";
cell = tableCal.rows[0].cells[1];
cell.innerText = "";
cell = tableCal.rows[0].cells[2];
cell.innerText = "";
cell = tableCal.rows[0].cells[3];
cell.innerText = "";
cell = tableCal.rows[0].cells[4];
cell.innerText = "";
cell = tableCal.rows[0].cells[5];
cell.innerText = "";
daily=1;
intDay=5;
startDay=1;
//cell.innerText = daily++;
}
else if((daily > 0) && (daily <= intdagIMaanad))
{
cell.innerText = daily++;
}
else
cell.innerText = "";
}
cell.focus()
}
function getDate() {
var sDate;
// This code executes when the user clicks on a day
// in the calendar.
if ("TD" == event.srcElement.tagName)
// Test whether day is valid.
if ("" != event.srcElement.innerText)
//alert(event.srcElement.innerText);
sDate =document.all.year.value+ "-" +document.all.month.value + "-" +
event.srcElement.innerText;
document.all.ret.value = sDate;
window.close();
}
</SCRIPT>
</HEAD>
<BODY ONLOAD="newCalendar()" OnUnload="window.returnValue = document.all.ret.value;">
<input type="hidden" name="ret">
<TABLE ID="calendar">
<THEAD>
<TR>
<TD COLSPAN=7 ALIGN=CENTER>
<!-- Year combo box -->
<font color=darkblue><b>År </b></font>
<SELECT ID="year" ONCHANGE="newCalendar()">
<SCRIPT LANGUAGE="JavaScript">
// Output years into the document.
// Select current year.
for (var intLoop = today.year-1; intLoop < (today.year+1);
intLoop++)
document.write("<OPTION VALUE= " + intLoop + " " +
(today.year-1 == intLoop ?
"Selected" : "") + ">" +
intLoop);
</SCRIPT>
</SELECT> <font color=darkblue><b>Månad </b></font>
<!-- Month combo box -->
<SELECT ID="month" ONCHANGE="newCalendar()">
<SCRIPT LANGUAGE="JavaScript">
// Output maanad into the document.
// Select current month.
for (var intLoop = 0; intLoop < maanad.length;
intLoop++)
document.write("<OPTION VALUE= " + (intLoop + 1) + " " +
(today.month == intLoop ?
"Selected" : "") + ">" +
maanad[intLoop]);
</SCRIPT>
</SELECT>
</TD>
</TR>
<TR CLASS="dagar">
<!-- Generate column for each day. -->
<SCRIPT LANGUAGE="JavaScript">
// Output dagar.
for (var intLoop = 0; intLoop < dagar.length;
intLoop++)
document.write("<TD>" + dagar[intLoop] + "</TD>");
</SCRIPT>
</TR>
</THEAD>
<TBODY ID="dayList" ONCLICK="getDate()" ALIGN="CENTER">
<!-- Generate grid for individual dagar. -->
<SCRIPT LANGUAGE="JavaScript">
for (var intWeeks = 0; intWeeks < 6; intWeeks++) {
document.write("<TR>"); // dagar array enligt ovan
for (var intdagar = 0; intdagar < dagar.length;intdagar++)
document.write("<TD></TD>");
document.write("</TR>");
}
</SCRIPT>
</TBODY>
</TABLE>
<center id=val>Välj År, månad och klicka på ett datum.
<Input id=knapp type=button value="Avbryt" OnClick="Cancel();"></center>
</BODY>
</HTML>
<Script Language="JavaScript1.2">
function Cancel() {
document.all.ret.value = "";
window.close();
}
</script>