function goNextMonth(month,year,form,field)
{
// If the month is December, increment the year.
if(month == 12)
{
++year;
month = 0;
}
document.location.href = 'calendar.php?month='+(month+1)+'&year='+year+'&form='+form+'&field='+field;
}
function sendToForm(val,field,form)
{
// Send back the date value to the form caller.
eval("opener.document." + form + "." + field + ".value='" + val + "'");
window.close();
}
</script>
</head>
<body style="margin:0px 0px 0px 0px" class="body">
<table width='175' border='0' cellspacing='0' cellpadding='0' class="body">
<tr>
<td width='25' colspan='1'>
<input type='button' class='button' value=' < ' onClick='<?php echo "goLastMonth($month,$year,\"$form\",\"$field\")"; ?>'>
</td>
<td width='125' align="center" colspan='5'>
<span class='title'><?php echo $monthName . " " . $year; ?></span><br>
</td>
<td width='25' colspan='1' align='right'>
<input type='button' class='button' value=' > ' onClick='<?php echo "goNextMonth($month,$year,\"$form\",\"$field\")"; ?>'>
</td>
</tr>
<tr>
<td class='head' align="center" width='25'>S</td>
<td class='head' align="center" width='25'>M</td>
<td class='head' align="center" width='25'>T</td>
<td class='head' align="center" width='25'>W</td>
<td class='head' align="center" width='25'>T</td>
<td class='head' align="center" width='25'>F</td>
<td class='head' align="center" width='25'>S</td>
</tr>
<tr>
<?php
for($i = 1; $i < $numDays+1; $i++, $counter++)
{
$timeStamp = strtotime("$year-$month-$i");
if($i == 1)
{
// Workout when the first day of the month is
$firstDay = date("w", $timeStamp);
Max Kipness wrote :1346
This did not seem to work because you were not checking to see if the variables were set in index.php. I`ve corrected this and now the code worked. Other than that it works good.
Revised index.php
<?php
// Get values from query string
if (isset($_GET["day"])) $day = $_GET["day"];
if (isset($_GET["month"]))$month = $_GET["month"];
if (isset($_GET["year"]))$year = $_GET["year"];
if (isset($_GET["sel"]))$sel = $_GET["sel"];
if (isset($_GET["what"]))$what = $_GET["what"];
if (isset($_GET["field"]))$field = $_GET["field"];
if (isset($_GET["form"]))$form = $_GET["form"];
function goNextMonth(month,year,form,field)
{
// If the month is December, increment the year.
if(month == 12)
{
++year;
month = 0;
}
document.location.href = `calendar.php?month=`+(month+1)+`&year=`+year+`&form=`+form+`&field=`+field;
}
function sendToForm(val,field,form)
{
// Send back the date value to the form caller.
eval("opener.document." + form + "." + field + ".value=`" + val + "`");
window.close();
}
</script>
</head>
<body style="margin:0px 0px 0px 0px" class="body">
<table width=`175` border=`0` cellspacing=`0` cellpadding=`0` class="body">
<tr>
<td width=`25` colspan=`1`>
<input type=`button` class=`button` value=` < ` onClick=`<?php echo "goLastMonth($month,$year,\"$form\",\"$field\")"; ?>`>
</td>
<td width=`125` align="center" colspan=`5`>
<span class=`title`><?php echo $monthName . " " . $year; ?></span><br>
</td>
<td width=`25` colspan=`1` align=`right`>
<input type=`button` class=`button` value=` > ` onClick=`<?php echo "goNextMonth($month,$year,\"$form\",\"$field\")"; ?>`>
</td>
</tr>
<tr>
<td class=`head` align="center" width=`25`>S</td>
<td class=`head` align="center" width=`25`>M</td>
<td class=`head` align="center" width=`25`>T</td>
<td class=`head` align="center" width=`25`>W</td>
<td class=`head` align="center" width=`25`>T</td>
<td class=`head` align="center" width=`25`>F</td>
<td class=`head` align="center" width=`25`>S</td>
</tr>
<tr>
<?php
for($i = 1; $i < $numDays+1; $i++, $counter++)
{
$timeStamp = strtotime("$year-$month-$i");
if($i == 1)
{
// Workout when the first day of the month is
$firstDay = date("w", $timeStamp);