zwei Kalendertage
Herbert1204
- javascript
0 ChrisB0 Herbert12040 Encoder
0 Shadowcrow
<head>
<script language="JavaScript" type="text/javascript">
// User Changeable Vars
var HighlightToday = true; // use true or false to have the current day highlighted
var DisablePast = true; // use true or false to allow past dates to be selectable
// The month names in your native language can be substituted below
var MonthNames = new Array("Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember");
// Global Vars
var now = new Date();
var dest = null;
var ny = now.getFullYear(); // Today's Date
var nm = now.getMonth();
var nd = now.getDate();
var sy = 0; // currently Selected date
var sm = 0;
var sd = 0;
var y = now.getFullYear(); // Working Date
var m = now.getMonth();
var d = now.getDate();
var l = 0;
var t = 0;
var MonthLengths = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
/*
Function: GetDate(control)
Arguments:
control = ID of destination control
*/
function GetDate() {
EnsureCalendarExists();
DestroyCalendar();
// One arguments is required, the rest are optional
// First arguments must be the ID of the destination control
if(arguments[0] == null || arguments[0] == "") {
// arguments not defined, so display error and quit
alert("ERROR: Destination control required in funciton call GetDate()");
return;
} else {
// copy argument
dest = arguments[0];
}
y = now.getFullYear();
m = now.getMonth();
d = now.getDate();
sm = 0;
sd = 0;
sy = 0;
var cdval = dest.startDate;
if(/d{1,2}.d{1,2}.d{4}/.test(dest.startDate)) {
// element contains a date, so set the shown date
var vParts = startDate.split("/"); // assume dd/mm/yyyy
sm = vParts[0] - 1;
sd = vParts[1];
sy = vParts[2];
m=sm;
d=sd;
y=sy;
}
var cdval = dest.endDate;
if(/d{1,2}.d{1,2}.d{4}/.test(dest.endDate)) {
// element contains a date, so set the shown date
var vParts = endDate.split("/"); // assume dd/mm/yyyy
sm = vParts[0] - 1;
sd = vParts[1];
sy = vParts[2];
m=sm;
d=sd;
y=sy;
}
// l = dest.offsetLeft; // + dest.offsetWidth;
// t = dest.offsetTop - 125; // Calendar is displayed 125 pixels above the destination element
// if(t<0) { t=0; } // or (somewhat) over top of it. ;)
/* Calendar is displayed 125 pixels above the destination element
or (somewhat) over top of it. ;)*/
l = dest.offsetLeft + dest.offsetParent.offsetLeft + 330;
t = dest.offsetTop + 0;
if(t < 0) t = 0; // >
DrawCalendar();
}
/*
function DestoryCalendar()
Purpose: Destory any already drawn calendar so a new one can be drawn
*/
function DestroyCalendar() {
var cal = document.getElementById("dpCalendar");
if(cal != null) {
cal.innerHTML = null;
cal.style.display = "none";
}
return
}
function DrawCalendar() {
DestroyCalendar();
cal = document.getElementById("dpCalendar");
cal.style.left = l + "px";
cal.style.top = t + "px";
var sCal = "<table><tr><td class="cellButton"><a href="javascript: PrevMonth();" title="Previous Month"><<</a></td>"+
"<td class="cellMonth" width="80%" colspan="5">"+MonthNames[m]+" "+y+"</td>"+
"<td class="cellButton"><a href="javascript: NextMonth();" title="Next Month">>></a></td></tr>"+
"<tr><td>So</td><td>Mo</td><td>Di</td><td>Mi</td><td>Do</td><td>Fr</td><td>Sa</td></tr>";
var wDay = 1;
var wDate = new Date(y,m,wDay);
if(isLeapYear(wDate)) {
MonthLengths[1] = 29;
} else {
MonthLengths[1] = 28;
}
var dayclass = "";
var isToday = false;
for(var r=1; r<7; r++) {
sCal = sCal + "<tr>";
for(var c=0; c<7; c++) {
var wDate = new Date(y,m,wDay);
if(wDate.getDay() == c && wDay<=MonthLengths[m]) {
if(wDate.getDate()==sd && wDate.getMonth()==sm && wDate.getFullYear()==sy) {
dayclass = "cellSelected";
isToday = true; // only matters if the selected day IS today, otherwise ignored.
} else if(wDate.getDate()==nd && wDate.getMonth()==nm && wDate.getFullYear()==ny && HighlightToday) {
dayclass = "cellToday";
isToday = true;
} else {
dayclass = "cellDay";
isToday = false;
}
if(((now > wDate) && !DisablePast) || (now <= wDate) || isToday) { // >
// user wants past dates selectable
sCal = sCal + "<td class=""+dayclass+""><a href="javascript: ReturnDay("+wDay+");">"+wDay+"</a></td>";
} else {
// user wants past dates to be read only
sCal = sCal + "<td class=""+dayclass+"">"+wDay+"</td>";
}
wDay++;
} else {
sCal = sCal + "<td class="unused"></td>";
}
}
sCal = sCal + "</tr>";
}
sCal = sCal + "<tr><td colspan="4" class="unused"></td><td colspan="3" class="cellCancel"><a href="javascript: DestroyCalendar();">Cancel</a></td></tr></table>"
cal.innerHTML = sCal; // works in FireFox, opera
cal.style.display = "inline";
}
function PrevMonth() {
m--;
if(m==-1) {
m = 11;
y--;
}
DrawCalendar();
}
function NextMonth() {
m++;
if(m==12) {
m = 0;
y++;
}
DrawCalendar();
}
function ReturnDay(day) {
var startDateValue = document.startDate.dest.value
var endDateValue = document.endDate.dest.value
dest.value = day+". "+MonthNames[m]+" "+y;
DestroyCalendar();
}
function EnsureCalendarExists() {
if(document.getElementById("dpCalendar") == null) {
var eCalendar = document.createElement("div");
eCalendar.setAttribute("id", "dpCalendar");
document.body.appendChild(eCalendar);
}
}
function isLeapYear(dTest) {
var y = dTest.getYear();
var bReturn = false;
if(y % 4 == 0) {
if(y % 100 != 0) {
bReturn = true;
} else {
if (y % 400 == 0) {
bReturn = true;
}
}
}
return bReturn;
}
</script>
<style type="text/css">
/* The containing DIV element for the Calendar */
#dpCalendar {
display: none; /* Important, do not change */
position: absolute /* Important, do not change */
background-color: #cccccc;
color: #000000;
font-size: xx-small;
font-family: Corbel, Geneva, Arial, Helvetica, sans-serif;
width: 150px;
}
/* The table of the Calendar */
#dpCalendar table {
border: 1px solid white;
background-color: #eeeeee;
color: #000000;
font-size: x-small;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
width: 100%;
}
/* The Next/Previous buttons */
#dpCalendar .cellButton {
background-color: #cccccc;
color: black;
}
/* The Month/Year title cell */
#dpCalendar .cellMonth {
background-color: #cccccc;
color: #000000;
text-align: center;
}
/* Any regular day of the month cell */
#dpCalendar .cellDay {
background-color: #cccccc;
color: #000000;
text-align: center;
}
/* The day of the month cell that is selected */
#dpCalendar .cellSelected {
border: 1px solid red;
background-color: #cccccc;
color: #cccccc;
text-align: center;
}
/* The day of the month cell that is Today */
#dpCalendar .cellToday {
background-color: #ffffff;
color: #666666;
text-align: center;
}
/* Any cell in a month that is unused (ie: Not a Day in that month) */
#dpCalendar .unused {
background-color: #cccccc;
color: green;
}
/* The cancel button */
#dpCalendar .cellCancel {
background-color: #cccccc;
color: black;
border: 1px solid #000000;
text-align: center;
}
/* The clickable text inside the calendar */
#dpCalendar a {
text-decoration: none;
background-color: cccccc;
color: #000000;
}
</style>
</head>
<body>
<table border="1">
<tr>
<td>
<form name="startDate">
<input type="text" readonly name="dest" style="font-weight:bold; font-size:11pt; text-align:center; border-color:white; border-style:solid; width:135px;"><br>
<input type="button" onClick="GetDate(dest);" value="Datum ändern" style="font-weight:bold; font-size:11pt; width:110px">
</form>
</td>
<td>
<form name="endDate">
<input type="text" readonly name="dest" style="font-weight:bold; font-size:11pt; text-align:center; border-color:white; border-style:solid; width:135px;"><br>
<input type="button" onClick="GetDate(dest);" value="Datum ändern" style="font-weight:bold; font-size:11pt; width:110px">
</form>
</td>
</tr>
</table>
</body>
Hi,
hat Copy&Paste dich mental so ausgelaugt, dass du vergessen hast, (d)eine Frage zu stellen - oder willst du nur das Forum als Spickzettel für eine Klausur o.ä. benutzen, bei der ihr hier zugreifen dürft ...?
MfG ChrisB
Hi,
hat Copy&Paste dich mental so ausgelaugt, dass du vergessen hast, (d)eine Frage zu stellen - oder willst du nur das Forum als Spickzettel für eine Klausur o.ä. benutzen, bei der ihr hier zugreifen dürft ...?
MfG ChrisB
sorry!!
Ich glaubte nicht, daß so ein langer text vom System angenommen wird.
Ich glaubte nicht, daß so ein langer text vom System angenommen wird.
Was den Sinn deines Beitrags aber immer noch nicht ganz klärt ;-)
'ǝɯɐu$ ıɥ
Ich glaubte nicht, daß so ein langer text vom System angenommen wird.
Was den Sinn deines Beitrags aber immer noch nicht ganz klärt ;-)
siehe sein Doppelposting:
Hallo
Ich habe ein Script (siehe unten) mit zwei Kalender. Bei beiden Kalender kann man nur das jeweilige Datum und ein Datum in der Zukunft auswählen. Soweit so gut. Jetzt soll aber das zweite Datum immer höher sein als das erste Datum sein. So und das ist das Problem!Kann mir jemand das Script entsprechend umschreiben?
Im Voraus schon einmal Vielen Dank
ssnɹƃ
ʍopɐɥs
'ǝɯɐu$ ıɥ
Hi,
hat Copy&Paste dich mental so ausgelaugt, dass du vergessen hast, (d)eine Frage zu stellen - oder willst du nur das Forum als Spickzettel für eine Klausur o.ä. benutzen, bei der ihr hier zugreifen dürft ...?
Nö, eher nicht, ich rate mal: der OP hat dieses Script im Netz gefunden und will wissen wie er es so verändert das er zwei Tage anstatt einem auswählen kann.
ssnɹƃ
ʍopɐɥs