Calender-Script gibt keinen Rückgabewert
Giovanni Rena
- javascript
Hallo, ich hab leider nicht viel mit JS am Hut, hab hier aber ein JS dass einen Kalender darstellt. In diesem Kalender kann man einen Tach auswählen und eigentlich sollte dieser in einem Eingabefeld dargestellt werden, was nicht geschieht. Hoffe mir kann jemand helfen.
Das ist das gesamte Script, aufgeteilt in mehrere Beiträge:
<?xml version="1.0" encoding=""?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title>
<script language="JavaScript" type="text/javascript"> var win = null; function NewWindow(mypage, myname, w, h, scroll) { var winl = (screen.width-w) / 2; var wint = (screen.height-h) / 2; var settings = 'height=' + h + ','; settings += 'width=' + w + ','; settings += 'top=' + wint + ','; settings += 'left=' + winl + ','; settings += 'scrollbars=' + scroll + ','; settings += 'resizable=no';
win = window.open (mypage, myname, settings); return win; }
defaultStatus = "Tobit Software";
<!-- function SendToStatusWindow(FormName, width, height) { if (!width) width=400; if (!height) height=200;
var frm; var left= (screen.width-width)/2; var top = (screen.height-height)/2; var settings = " dependent=yes,"+ " hotkeys=no," + " menubar=no," + " locationbar=no," + " status=no," + " height=" + height + "," + " width=" + width + "," + " top=" + top + "," + " left=" + left; frm = eval("document.forms." + FormName); frm.target="StatusWindow"; //window.open("about:blank", "StatusWindow", settings, true); tmp = window.open("/include/EmptyStatusWin.htm", "StatusWindow", settings, true); tmp.focus();
return true; }
function SendURLToStatusWindow(url, width, height) { if (!width) width=400; if (!height) height=200;
var left= (screen.width-width)/2; var top = (screen.height-height)/2; var settings = " dependent=yes,"+ " hotkeys=no," + " menubar=no," + " locationbar=no," + " status=no," + " height=" + height + "," + " width=" + width + "," + " top=" + top + "," + " left=" + left; //window.open("about:blank", "StatusWindow", settings, true); tmp = window.open(url, "StatusWindow", settings, true); tmp.focus();
return true; }
//--> </script> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5" />
<style> td.cal { font-family: Arial, Helvetica, sans-serif; font-size: 11px; line-height:11px; color: #000000; border-right:1px solid #000000; text-align:center; vertical-align: middle; cursor:hand; width:20px; height:10px; } td.none { font-family: Arial, Helvetica, sans-serif; font-size: 11px; line-height: 11px; color: #000000; text-align:center; vertical-align: middle; cursor:hand; width:20px; height:10px; } td.blank { font-family: Arial, Helvetica, sans-serif; font-size: 11px; line-height: 11px; color: #000000; background-color:#FFFFFF; text-align:center; vertical-align: middle; cursor:default; width:20px; } td.head { font-family: Arial, Helvetica, sans-serif; font-size:11px; line-height: 11px; color: #000000; background-color:#FFFFFF; border-right:1px solid #000000; border-bottom:1px solid #000000; text-align:center; vertical-align: middle; padding-bottom:3px; } font.cal { font-family: tahoma,arial; line-height:13px; font-size:11px; } td.caltbl { border:1px solid #FFFFFF; background-color:#FFFFFF; text-align:center; vertical-align: middle; height:10px; } </style> <script language="JavaScript" type="text/javascript"> <!-- /* Hinweise zum Implementieren: Der Aufruf des Kalenders erfolgt mit: showCal(Zielobjekt, xpos, ypos) Am Ende wird die Funktion extFunc() aufgerufen, die zur weiteren Auswertung des ermittelten Datums nach dem Kalenderinclude überschrieben werden kann. */
monthlist = new Array( "Januar","Februar","März","April", "Mai","Juni","Juli","August","September", "Oktober","November","Dezember" );
thisdate = new Date(); var debugCal = false; var thisDay = thisdate.getDate(); var thisMonth = thisdate.getMonth(); var thisYear = thisdate.getYear(); if (thisYear < 1900) thisYear += 1900; var minYear = thisYear - 80; var maxYear = thisYear + 20; var showYear=thisYear; var showMonth=thisMonth; var showDay=thisDay; var dateobj; var beginflag=0; var holnoclick = false;
var conststr1 = "<table width="170" cellpadding="0" cellspacing="0" height="150" style="border:1px solid #000000">" + "<tr><td valign="top" style="border:3px solid #9D98D8"><table border="0" cellpadding="0" cellspacing="0" style="border-bottom:3px solid #9D98D8">" + "<tr><td bgcolor="#9D98D8" align="left" style="border-right:3px solid #9D98D8;"><select class="selectBoxCal" onchange="SelectMonthYear()" onMouseOver="this.focus();" name="month_select" style="width:100px;">";
for(var i=0; i<12; i++) { conststr1 += "<option value="" +i+ """; if(i == thisMonth) conststr1 += " selected";
conststr1 += ">" +monthlist[i]+ "</option>\n"; } conststr1 += "</select></td><td bgcolor="#9D98D8" align="right">" + "<select class="selectBoxCal" name="year_select" onchange="SelectMonthYear()" onMouseOver="this.focus();" style="width:59px;">";
for(i=minYear; i<=maxYear; i++) { conststr1 += "<option value="" +i+ """; if(i == thisYear) conststr1 += " selected";
conststr1 += ">" +i+ "</option>\n"; } conststr1 += "</select></td></tr></table>";
var conststr2= "<table border="0" cellpadding="0" cellspacing="0" width="100%" style="border:5px solid #FFFFFF" bgcolor="#FFFFFF">" + "<tr><td class="blank"><table border="0" cellpadding="0" cellspacing="0" align="right" width="20" style="border-bottom:1px solid #000000; border-right:1px solid #000000;"><tr><td valign="middle"><font class="cal" style="padding-left:1px;">Mo</font></td></tr></table></td>"+ "<td class="blank"><table border="0" cellpadding="0" cellspacing="0" align="center" width="22" style="border-bottom:1px solid #000000; border-right:1px solid #000000;"><tr><td align="center" valign="middle"><font class="cal">Di</font></td></tr></table></td>"+ "<td class="blank"><table border="0" cellpadding="0" cellspacing="0" align="center" width="22" style="border-bottom:1px solid #000000; border-right:1px solid #000000;"><tr><td align="center" valign="middle"><font class="cal">Mi</font></td></tr></table></td>"+ "<td class="blank"><table border="0" cellpadding="0" cellspacing="0" align="center" width="22" style="border-bottom:1px solid #000000; border-right:1px solid #000000;"><tr><td align="center" valign="middle"><font class="cal">Do</font></td></tr></table></td>"+ "<td class="blank"><table border="0" cellpadding="0" cellspacing="0" align="center" width="22" style="border-bottom:1px solid #000000; border-right:1px solid #000000;"><tr><td align="center" valign="middle"><font class="cal">Fr</font></td></tr></table></td>"+ "<td class="blank"><table border="0" cellpadding="0" cellspacing="0" align="center" width="22" style="border-bottom:1px solid #000000; border-right:1px solid #000000;"><tr><td align="center" valign="middle"><font class="cal" color="#900000">Sa</font></td></tr></table></td>"+ "<td class="blank"><table border="0" cellpadding="0" cellspacing="0" align="left" width="18" style="border-bottom:1px solid #000000;"><tr><td align="right" valign="middle"><font class="cal" color="#900000" style="padding-right:1px">So</font></td></tr></table></td></tr>";
var conststr3= "</table></td></tr></table>";
function SelectMonthYear() { var yearIndex = document.getElementById ("year_select").selectedIndex;
showMonth = document.getElementById ("month_select").selectedIndex; showYear = document.getElementById ("year_select")[yearIndex].value;
makecal(); document.getElementById ("month_select").selectedIndex = showMonth; document.getElementById ("year_select").selectedIndex = yearIndex; }
function get_days(objdate) { var monthnr=objdate.getMonth(); for(var i=28;i<=31;i++) { objdate.setDate(i); if(objdate.getMonth() != monthnr) break; } return --i; }
function makecal (selType) { if (!selType) selType = "year-"; selMonth = new Date(showYear, showMonth, 1); preMonth = new Date(showYear, showMonth-1, 1); postMonth= new Date(showYear, showMonth+1, 1);
var firstofMonth = selMonth.getDay(); if(firstofMonth==0) firstofMonth=7; var monthnr = selMonth.getMonth(); var daystr=""; var dcol=""; var rows=0; var counter=1; var dayclick = "";
nrofdays=get_days(selMonth); prenrofdays=get_days(preMonth); preMonth.setMonth(showMonth-1); postnrofdays=get_days(postMonth); postMonth.setMonth(showMonth+1);
for(i=1;i<=firstofMonth-1;i++) { var tempint=prenrofdays-firstofMonth+i+1; dcol="#606060"; fontw="";
if((counter)%7==1) daystr += "<tr>"; if((counter)%7==6) dcol="#600000"; if(tempint==thisDay && preMonth.getMonth()==thisMonth && showYear==thisYear) {fontw="<B>"; dcol="#c00000";} else if(tempint==thisDay && preMonth.getMonth()==11 && preMonth.getMonth()==thisMonth && showYear-1==thisYear) { fontw="<B>"; dcol="#c00000"; } dayclick = " onMouseover="releaseCap('past_"+i+"',true);" onMouseout="setCap('past_"+i+"')" onClick="calout("+tempint+",-1)""; if (((counter)%7==0 || (counter)%7==6) && holnoclick) dayclick = "";
daystr += "<td class="cal" " + dayclick + ">" + "<table border="0" cellpadding="0" height="16" cellspacing="0" width="100%" style="border:1px solid #FFFFFF; border-bottom:0px;"><tr><td>"+ "<table border="0" cellpadding="0" height="14" cellspacing="0" width="100%">"+ "<tr><td class="caltbl" id="past_"+i+"" style="padding-left:1px;">"+ "<font class="cal" color="" + dcol + "">" + fontw + tempint + "</font>"+ "</td></tr></table></td></tr></table>"+ "</td>";
counter++; }
for(i=1;i<=nrofdays;i++) { dcol=0; fontw=""; if(rows == 0) var strstyle = "border:1px solid #FFFFFF; border-bottom:0px;"; else var strstyle = "border:1px solid #FFFFFF; border-bottom:0px; border-top:0px;"; if((counter)%7==1) daystr += "<tr>"; if((counter)%7==6 || (counter)%7==0) dcol="#900000"; if(i==thisDay && monthnr==thisMonth && showYear==thisYear) {fontw="<B>"; dcol="#c00000";}
dayclick = "onMouseover="releaseCap('now_"+i+"',true);" onMouseout="setCap('now_"+i+"')" onClick="calout("+i+",0)"";
if (((counter)%7==0 || (counter)%7==6) && holnoclick) dayclick = "";
if((counter)%7==0) { daystr += "<td class="none" " + dayclick + ">"+ "<table border="0" height="16" cellpadding="0" cellspacing="0" width="100%" style=""+strstyle+""><tr><td>"+ "<table border="0" height="14" cellpadding="0" cellspacing="0" width="100%">"+ "<tr><td class="caltbl" id="now_"+i+"" style="padding-left:1px;">"+ "<font class="cal" color="" + dcol + "">" + fontw + i + "</font>"+ "</td></tr></table></td></tr></table>"+ "</td></tr>"; rows++; } else { daystr += "<td class="cal" " + dayclick + ">"+ "<table border="0" height="16" cellpadding="0" cellspacing="0" width="100%" style=""+strstyle+""><tr><td>"+ "<table border="0" height="14" cellpadding="0" cellspacing="0" width="100%">"+ "<tr><td class="caltbl" id="now_"+i+"" style="padding-left:1px;">"+ "<font class="cal" color="" + dcol + "">" + fontw + i + "</font>"+ "</td></tr></table></td></tr></table>"+ "</td>"; } counter++; }
for(i=1;counter<=42;i++) { if((counter)%7==1) daystr += "<tr>"; dcol="#606060"; fontw=""; if((counter)%7==6 || (counter)%7==0) dcol="#600000"; if(i==thisDay && postMonth.getMonth()==thisMonth && showYear==thisYear) {fontw="<B>"; dcol="#c00000";} else if(i==thisDay && postMonth.getMonth()==0 && postMonth.getMonth()==thisMonth && showYear+1==thisYear) { fontw="<B>"; dcol="#c00000"; } dayclick = " onMouseover="releaseCap('fut_"+i+"',true);" onMouseout="setCap('fut_"+i+"')" onClick="calout("+i+",1)""; if (((counter)%7==0 || (counter)%7==6) && holnoclick) dayclick = "";
if((counter)%7==0) { daystr += "<td class="none" " + dayclick + ">"+ "<table border="0" height="16" cellpadding="0" cellspacing="0" width="100%" style="border:1px solid #FFFFFF; border-top:0px; border-bottom:0px;"><tr><td>"+ "<table border="0" height="14" cellpadding="0" cellspacing="0" width="100%">"+ "<tr><td class="caltbl" id="fut_"+i+"" style="padding-left:1px;">"+ "<font class="cal" color="" + dcol + "">" + fontw + i + "</font>"+ "</td></tr></table></td></tr></table>"+ "</td></tr>"; rows++; } else { daystr += "<td class="cal" " + dayclick + ">"+ "<table border="0" height="16" cellpadding="0" cellspacing="0" width="100%" style="border:1px solid #FFFFFF; border-top:0px; border-bottom:0px;"><tr><td>"+ "<table border="0" height="14" cellpadding="0" cellspacing="0" width="100%">"+ "<tr><td class="caltbl" id="fut_"+i+"" style="padding-left:1px;">"+ "<font class="cal" color="" + dcol + "">" + fontw + i + "</font>"+ "</td></tr></table></td></tr></table>"+ "</td>"; } counter++; }
daystr += "</tr>"; document.getElementById ("calendar").innerHTML = conststr1 + conststr2 + daystr + conststr3; }
var captureCtrl = true; var selectionType = ""; function showSelection (type) { selectionType = type; captureCtrl = false; releaseCap (null, false); document.getElementById ("calendarSelect").style.top=calyPos;
if (type == "year-") { document.getElementById ("calendarSelect").style.left=calxPos + 40; htmlText = "<select id="selection" style="width:56px; font-size:10px;" onBlur="selChange()" onChange="selChange()">"; for (i = thisYear + 10; i > thisYear - 70; i--) { htmlText += "<option value=" + i + (i == thisYear ? " selected" : "") + ">" + i + "</option>\r\n"; } htmlText += "</select>"; document.getElementById ("calendarSelect").innerHTML = htmlText; }
if (type == "year+") { document.getElementById ("calendarSelect").style.left=calxPos + 40; htmlText = "<select id="selection" style="width:56px; font-size:10px;" onBlur="selChange()" onChange="selChange()">"; for (i = thisYear; i < thisYear + 10; i++) { htmlText += "<option value=" + i + ">" + i + "</option>\r\n"; } htmlText += "</select>"; document.getElementById ("calendarSelect").innerHTML = htmlText; document.getElementById ("selection").selectedIndex = 0; }
if (type == "month") { document.getElementById ("calendarSelect").style.left=calxPos + 27; htmlText = "<select id="selection" style="width:80px; font-size:10px;" onBlur="selChange()" onChange="selChange()">"; for (i = 0; i < 12; i++) { htmlText += "<option value=" + i + ">" + monthlist[i] + "</option>" } htmlText += "</select>"; document.getElementById ("calendarSelect").innerHTML = htmlText; document.getElementById ("selection").selectedIndex = showMonth; } makecal (); document.getElementById ("selection").focus (); }
3. Teil
function selChange ()
{
if (selectionType.indexOf ("month") != -1)
showMonth = document.getElementById ("selection").value * 1;
else
showYear = document.getElementById ("selection").value * 1;
document.getElementById ("calendarSelect").innerHTML = "";
captureCtrl = true;
makecal ();
}
function setCap(id)
{
if (captureCtrl && document.getElementById ("calendar").setCapture)
document.getElementById ("calendar").setCapture(false);
var obj = document.getElementById(id);
obj.style.border= "1px solid #FFFFFF";
obj.style.backgroundColor = "#FFFFFF";
}
function releaseCap(id, param)
{
if(param == false && document.getElementById ("calendar").releaseCapture)
{
document.getElementById ("calendar").releaseCapture();
}
else
{
var obj = document.getElementById(id);
obj.style.border= "1px solid #4E5166";
obj.style.backgroundColor = "#C7CCF2";
if (document.getElementById ("calendar").releaseCapture)
document.getElementById ("calendar").releaseCapture();
}
}
function calout(daynr, minc)
{
var tempint = showMonth + 1 + minc;
var tempyear = showYear;
if(tempint == 13) {tempint = 1; showYear++; tempyear++; showMonth = -1;}
if(tempint == 0) {tempint = 12; tempyear--;}
if(minc > 0) showMonth++;
dateStr = daynr + "." + tempint + "." + tempyear;
dateobj.value = dateStr;
//korrektur für wiederholten start
showYear = thisYear;
showMonth = thisMonth;
clearCal ();
}
function CalClick()
{
if( window.event.srcElement.tagName != "SELECT")
{
if(window.event.srcElement.tagName != "TD" )
clearCal();
clearCal ();
}
}
function keyHandler()
{
if(window.event.keyCode == 27) clearCal();
}
function clearCal()
{
if (!captureCtrl)
{
selChange ();
return;
}
document.getElementById ("calendar").innerHTML=" ";
if (document.getElementById ("calendar").releaseCapture)
document.getElementById ("calendar").releaseCapture();
document.body.onkeydown = document.getElementById ("calendar").onkeydown;
extFunc();
}
function extFunc()
{
return;
}
function debAltr (debStr)
{
if (debugCal)
alert (debStr);
}
var calxPos = 0;
var calyPos = 0;
function showCal(target, xpos, ypos, selType, _debug, hideholiday)
{
var clientWidth = document.body.clientWidth;
var xOffset = Math.floor ((clientWidth - 752) / 2) - 300;
xOffset = 0;
if (!selType)
selType = "year-";
if (_debug)
debugCal = true;
if (hideholiday)
holnoclick = true;
dateobj=eval(target);
document.getElementById ("calendar").onKeyDown = document.body.onkeydown;
document.body.onkeydown = keyHandler;
if (document.getElementById ("calendar").setCapture)
document.getElementById ("calendar").setCapture(false);
if (document.getElementById ("calendar").innerHTML != " " && document.getElementById ("calendar").innerHTML != "")
clearCal();
else
{
calxPos = xpos;
calyPos = ypos;
document.getElementById ("calendar").style.left = xpos + xOffset + "px";
document.getElementById ("calendar").style.top = ypos + "px";
makecal (selType);
}
}
// -->
</script>
</head>
<div id="calendar" onClick="CalClick()" style="position:absolute; z-index:50;"> </div>
<div id="calendarSelect" style="position:absolute; z-index:99;"></div>
<script language="JavaScript" src="/include/Datefunctions.js" type="text/javascript"></script>
<head>
<style>
<!--
.tdTitle {background-color:#a0a0a0; font-family:"TAHOMA, HELVETICA, SANS-SERIF"; font-size:8pt; color:#000000; font-weight:bold}
.tdDefault {background-color:#e4e4e4; font-family:"TAHOMA, HELVETICA, SANS-SERIF"; font-size:8pt; color:#000000}
.tdDefault2{background-color:#f0f0f0; font-family:"TAHOMA, HELVETICA, SANS-SERIF"; font-size:8pt; color:#000000}
.tdWhite {background-color:#ffffff; font-family:"TAHOMA, HELVETICA, SANS-SERIF"; font-size:8pt; color:#000000; text-align=right}
-->
</style>
<script language="JavaScript" type="text/javascript">
function chkselect ()
{
if (document.SupCallData.callhour.selectedIndex == 0)
document.SupCallData.callminute.selectedIndex = 1;
}
function extFunc()
{
document.SupCallData.CalltimeDisplay.value = FormatDate( parseGermanDate(document.SupCallData.CallDatetime.value) ,"#dd#-#monthshort#-#yyyy#", "ger");
}
</script>
<script language="JavaScript" type="text/javascript">
<!--
var selectedPoint = "";
function chgBorder (tdID, statusID, title)
{
if (statusID == 1)
{
document.getElementById (tdID).style.border = "1px solid #4E5166";
document.getElementById (tdID).style.backgroundColor = "#C7CCF2";
document.getElementById (tdID).style.backgroundImage = "url(/graphic/Club-Menue-Background.gif)";
document.getElementById ("lnk_" + tdID).className = "MenuLinkSelect";
top.status = title;
return true;
}
else
{
document.getElementById (tdID).style.border = "1px solid white";
document.getElementById (tdID).style.backgroundColor = "white";
document.getElementById (tdID).style.backgroundImage = "";
if (tdID != selectedPoint)
document.getElementById ("lnk_" + tdID).className = "MenuLink";
top.status = "Tobit Software";
}
}
function setMenuPoint (tdID)
{
if (selectedPoint != "")
{
document.getElementById (selectedPoint).style.border = "1px solid white";
document.getElementById (selectedPoint).style.backgroundColor = "white";
document.getElementById ("lnk_" + selectedPoint).className = "MenuLink";
}
selectedPoint = tdID;
document.getElementById (tdID).style.border = "1px solid white";
document.getElementById (tdID).style.backgroundColor = "white";
document.getElementById ("lnk_" + tdID).className = "MenuLinkSelect";
}
//-->
</script>
<p> </p>
<form action="RequestSupportCall_Save.asp" method="post" name="SupCallData" id="SupCallData">
Zeitpunkt
<input type="hidden" name="CallDatetime" value="19.02.2004" />
<input readonly"readonly" class="inputfld" type="text" name="CalltimeDisplay" size="9" value="" />
<img src="/graphic/calendar.gif" width="14" height="14" border="0" alt="calendar" onclick="showCal(document.SupCallData.CallDatetime,200,10, null, null, false)" style="cursor:hand;" />
</form>
</body>
</html>