Hello:
I found a calendar script where the calendar has a drop down box for the month and year.
Right now, the script has you select the month and/or year and click Go.
Rather than clicking Go, I would like to have people select the month and the calendar automatically change to that month.
Can anyone help me out?
Thanks in advance.
Here is the script:
<?php
define("ADAY", (606024));
if (!checkdate($POST['month'], 1, $POST['year'])) {
$nowArray = getdate();
$month = $nowArray['mon'];
$year = $nowArray['year'];
} else {
$month = $POST['month'];
$year = $POST['year'];
}
$start = mktime (12, 0, 0, $month, 1, $year);
$firstDayArray = getdate($start);
?>
<html>
<head>
<title><?php echo "Calendar:".$firstDayArray['month']." ".$firstDayArray['year'] ?></title>
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<form method="post" action="<?php echo "$_SERVER[PHP_SELF]"; ?>">
<select name="month">
<?php
$months = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
for ($x=1; $x <= count($months); $x++) {
echo"<option value=\"$x\"";
if ($x == $month) {
echo " SELECTED";
}
echo ">".$months[$x-1]."";
}
?>
</select>
<select name="year">
<?php
for ($x=1980; $x<=2010; $x++) {
echo "<option";
if ($x == $year) {
echo " SELECTED";
}
echo ">$x";
}
?>
</select>
<input type="submit" value="Go!">
</form>
<br>
<?php
$days = Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
echo "<TABLE BORDER=1 CELLPADDING=5><tr>\n";
foreach ($days as $day) {
echo "<TD width=\"10%\" BGCOLOR=\"#CCCCCC\" ALIGN=CENTER><font face=\"verdana\" font size=\"1\"><strong>$day</strong></font></td>\n";
}
for ($count=0; $count < (6*7); $count++) {
$dayArray = getdate($start);
if (($count % 7) == 0) {
if ($dayArray['mon'] != $month) {
break;
} else {
echo "</tr><tr>\n";
}
}
if ($count < $firstDayArray['wday'] || $dayArray['mon'] != $month) {
echo "<td height=\"100\" valign=\"top\" align=\"right\"><font face=\"verdana\" font size=\"1\"> </td>\n";
} else {
echo "<td height=\"100\" valign=\"top\" align=\"right\"><font face=\"verdana\" font size=\"1\">".$dayArray['mday']." </td>\n";
$start += ADAY;
}
}
echo "</tr></table>";
?>
</body>
</html>