Bräuchte Hilfe bei meinem Kalender :)

Yukari

Grünschnabel
Hallo zusammen,
hoffentlich kann mir von euch jemand weiterhelfen, da ich im Moment ziemlich auf der Stelle trete. Ich habe einen kleinen Kalender geschrieben mit dem man ein bestimmtes Datum auswählen kann (für eine Art Terminplaner gedacht). Das ausgewählte Datum soll dann im Textfeld erscheinen. Leider bekomme ich das einfach nicht hin. Für Lösungsvorschläge oder Tipps wäre ich sehr dankbar.

Hier mein Quellcode dazu:
calendar.php:
PHP:
<html>
<head>
	<style type="text/css">
		a:link { text-decoration:none; font-weight:bold; color:#104E8B; }
		a:visited { text-decoration:none; font-weight:bold; color:#104E8B; }
		a:hover { text-decoration:none; font-weight:bold; background-color:#E0FFFF; }
		a:active { text-decoration:none; font-weight:bold; background-color:#E0FFFF; }
		a:focus { text-decoration:none; font-weight:bold; background-color:#E0FFFF; }
	</style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
<font face="Arial" color="#104E8B" size="2">
	<script type="text/javascript">
		var angeschaltet = 0;
		function anzeigen(das){
			if(angeschaltet != 0){
		  		document.getElementById(angeschaltet).style.display='none';
		 	}
		 	if(document.getElementById(das).style.display=='none'){
		  		document.getElementById(das).style.display='block';
		 	}else{
		  		document.getElementById(das).style.display='none';
		  	}
		}
		angeschaltet= das;
	</script> 
<table cellspacing="0" cellpadding="0">
	<tr>
		<td valign="top">
			<form action="calendar.php" method="post">
				<input name="calendar" type="text" size="10" maxlength="10">
			</form>
		</td>
		<td valign="top">
			<a href="#" onclick="anzeigen('calendarbox')">Kalender</a>
		</td>
	</tr>
</table>	

<div id="calendarbox" style="display:none;position:fixed;left:20;top:20;solid #840; margin:1em;">
	<iframe src="cal.php" style="width:380px; height:200px" frameborder="1"></iframe>
</div>
</font>
</body>
</html>

cal.php:
PHP:
<?php
function get_month($m){
	switch($m){
		case 1:
			$mo = "Januar";
			break;
		case 2:
			$mo = "Februar";
			break;
		case 3:
			$mo = "März";
			break;
		case 4:
			$mo = "April";
			break;
		case 5:
			$mo = "Mai";
			break;
		case 6:
			$mo = "Juni";
			break;
		case 7:
			$mo = "Juli";
			break;
		case 8:
			$mo = "August";
			break;
		case 9:
			$mo = "September";
			break;
		case 10:
			$mo = "Oktober";
			break;
		case 11:
			$mo = "November";
			break;
		case 12:
			$mo = "Dezember";
			break;		
	}	
	return $mo;
}
function get_weekday($w){
	switch($w){
		case 0:
			$wd = "Sonntag";
			break;
		case 1:
			$wd = "Montag";
			break;
		case 2:
			$wd = "Dienstag";
			break;
		case 3:
			$wd = "Mittwoch";
			break;
		case 4:
			$wd = "Donnerstag";
			break;
		case 5:
			$wd = "Freitag";
			break;
		case 6:
			$wd = "Samstag";
			break;
	}	
	return $wd;
}

echo'
<html>
<head>
	<style type="text/css">
	a:link { text-decoration:none; font-weight:bold; color:#104E8B; }
	a:visited { text-decoration:none; font-weight:bold; color:#104E8B; }
	a:hover { text-decoration:none; font-weight:bold; background-color:#E0FFFF; }
	a:active { text-decoration:none; font-weight:bold; background-color:#E0FFFF; }
	a:focus { text-decoration:none; font-weight:bold; background-color:#E0FFFF; }
	</style>	
</head>
<body>
<font face="Arial" color="#104E8B" size="2">';
	
$darkblue = '#8DB6CD';
$blue = '#87CEFA';
$lightblue = '#CAE1FF';
$white = '#FFFFFF';

$newday = $_GET["newday"];
$newmonth = $_GET["newmonth"];
$newyear = $_GET["newyear"];

$time = time();
$dayj = date("j",$time); //Tag ohne führende Null
$month = date("n",$time); //Monatszahl ohne führende Null
$year = date("Y",$time); //Jahreszahl vierstellig

if($newday==""){$newday = $dayj;}
if($newmonth==""){$newmonth = $month;}else{$month = $newmonth;}
if($newyear==""){$newyear = $year;}else{$year = $newyear;}

$newdate = mktime(0,0,0,$month,$newday,$year);
$day = date("d",$newdate); //Tag mit führender Null
$dayj = date("j",$newdate); //Tag ohne führende Null
$month = date("n",$newdate); //Monatszahl ohne führende Null
//Monat vor dem aktuellen Monat
if($month==1){$bmonth = 12;$byear=$year-1;}else{$bmonth = $month-1;$byear=$year;}
//Monat nach dem aktuellen Monat
if($month==12){$nmonth = 1;$nyear=$year+1;}else{$nmonth = $month+1;$nyear=$year;}
$monthF = get_month($month);//Monat als ganzes Wort
$year = date("Y",$newdate); //Jahreszahl vierstellig
$days = date("t",$newdate); //Tage des Monats (28-31)
//$weekday = date("l",$newdate); //Ausgeschriebener Wochentag
$weekday = get_weekday(date("w",$newdate));

$date = mktime(0,0,0,$month,1,$year);
$wday = date("w",$date);//Wochentag als Zahl (0:So,1:Mo,2:Di,3:Mi,4:Do,5:Fr,6:Sa)

echo'<table width="360px" bgcolor="'.$darkblue.'"><tr><td align="center" valign="center">
	<table width="350px" border="0" bgcolor="'.$lightblue.'" cellspacing="0">
		<tr bgcolor="'.$darkblue.'">
			<td align="center" valign="center">
				<a href="cal.php?newday='.$newday.'&newmonth='.$bmonth.'&newyear='.$byear.'&vis=block"> < </a>
			</td>
			<td colspan="5" align="center"><font color='.$white.'><b>'.$weekday." - ".$day.". ". $monthF." ".$year.'</b></font></td>
			<td align="center" valign="center">
				<a href="cal.php?newday='.$newday.'&newmonth='.$nmonth.'&newyear='.$nyear.'&vis=block"> > </a>
			</td>
		</tr>
		<tr align="center" valign="center" bgcolor="'.$darkblue.'">
			<td width="50px"><font color='.$white.'><b>Mo</b></font></td>
			<td width="50px"><font color='.$white.'><b>Di</b></font></td>
			<td width="50px"><font color='.$white.'><b>Mi</b></font></td>
			<td width="50px"><font color='.$white.'><b>Do</b></font></td>
			<td width="50px"><font color='.$white.'><b>Fr</b></font></td>
			<td width="50px"><font color='.$white.'><b>Sa</b></font></td>
			<td width="50px"><font color='.$white.'><b>So</b></font></td>
		</tr>
		<tr>';

$done = false;
$n = 1;
for($i=1; $i<=$days; $i++){
	//Leerstellen vor dem 1. Tag des Monats
	if(!$done){for($l=1;$l<$wday;$l++){echo'<td></td>';$n++;$done = true;}} 
	//nächste Zeile nach 7 Tagen
	if($n > 7){echo'</tr><tr>';$n = 1;}
	// Heutigen bzw. ausgewählten Tag markieren
	if($i==$dayj && $dayj==$newday){$color = $blue;}else{$color = $lightblue;}
	echo'<td bgcolor="'.$color.'" align="center" valign="center">
		<a href="cal.php?newday='.$i.'&newmonth='.$month.'&newyear='.$year.'"> '.$i.' </a>
	</td>';
	$n++;
}

echo'</tr>';
echo '<tr><td colspan="7" align="center">newdate => '.$newdate.' => '.date("d.m.Y", $newdate).'</td></tr></table>
</td></tr>
</table>';

echo'</font>
</body>
</html>';

?>
 
Zurück