Thank you very much for your suggestion. I've downloaded the file and saved your code and am trying it out, but have never worked with javascript before and can't seem to make it work yet. I'll keep trying.
Still, it does seem to be a lot fussier/more code (but maybe it does a bunch of stuff that mine won't be able to do)
I've gotten closer to what I want with only 6K of basic php. But it requires radio buttons...I'd like them to just be tiny square buttons with the dates on each.
Save/call it as "xcal9r.php" if you want it to see it work.
<html>
<head>
<title>Joe's handy dandy calendar control</title>
<STYLE TYPE="text/css">
.puny_yellow {
width: 20px;
height: 20px;
background-color:yellow;
border-color:efefef;
color: blue;
font-weight: bold;
font-family: arial, verdana, ms sans serif;
font-size: 8pt;}
.puny_red {
width: 20px;
height: 20px;
background-color:red;
border-color:efefef;
color: white;
font-weight: bold;
font-family: arial, verdana, ms sans serif;
font-size: 8pt;}
.puny_blue {
width: 20px;
height: 20px;
background-color:blue;
border-color:efefef;
color: white;
font-weight: bold;
font-family: arial, verdana, ms sans serif;
font-size: 8pt;}
</STYLE>
</head>
<body style="font-family: Arial; font-size: 8pt">
<?
// POSTED VALUES
foreach($_POST as $postkey=>$postval) {$$postkey=$postval;
}
//echo "$$postkey:$postval<br>";} //DEBUG
// END POSTED VALUES
// Convert posted date string into time string
if(isset($raw_date) and $raw_date!="") {
$raw_time=strtotime($raw_date);
$datename="Selected date";
} else {
$raw_time=strtotime(date('Y-m-d'));
$datename="Default date (today)";}
// END Convert posted date string into time string
//calendar form based on picked date
// Date formatted/parsed for various purposes
$firstday=date('m/1/Y',$raw_time);
$picked_date=date('Y-m-d',$raw_time);
$picked_comppart=date('Y-m-',$raw_time); // used for comparison and creating select date string buttons
$picked_mo_yr=date('Y-m', $raw_time);
$picked_topbar=date('F Y', $raw_time);
$picked_month_length=date('t', $raw_time);
$picked_month=date('m', $raw_time); //month without leading zero
$picked_year=date('Y', $raw_time);
$raw_time_firstday=strtotime($firstday);
$picked_month_startday=date('m', $raw_time_firstday); //numeric value of the day of week 0=sunday 6=saturday
$current_compstring=date('Y-m-d'); // used for comparison if it is TODAY
$spacecounter=(1-$picked_month_startday); //starting point for the calendar date cells
echo "Red cell shows current date<br>";
echo "Blue/clicked cell shows selected date<br>";
echo "$datename: $picked_date<br>"; // show the default date or the date that was picked
echo "current compstring: $current_compstring<br>"; // show the default date or the date that was picked
// figure out previous month and next month
if($picked_month=="1") {
$prev_yr=$picked_year-01; $prev_month="$prev_yr-12-01";
} else {
$prev_mo=$picked_month-01; $prev_month="$picked_year-$prev_mo-01";}
if($picked_month=="12") {
$next_yr=$picked_year+1; $next_month="$next_yr-01-01";
} else {
$next_mo=$picked_month+1; $next_month="$picked_year-$next_mo-01";}
echo "<br>";
// end figure out previous month and next month
//a one month calendar control
echo "<table>";
echo "<tr><th><form method=\"POST\" action=\"xcal9r.php\" target=\"_self\">
<input type=\"hidden\" name=\"raw_date\" value=\"$prev_month\">
<input type=\"submit\" value=\"<<\" class=\"puny_red\">
</th></form><th colspan=5>$picked_topbar</th><th><form method=\"POST\" action=\"xcal9r.php\" target=\"_self\">
<input type=\"hidden\" name=\"raw_date\" value=\"$next_month\">
<input type=\"submit\" value=\">>\" class=\"puny_red\">
</th></form></tr>";
echo "<form method=\"POST\" action=\"xcal9r.php\" target=\"_self\">";
echo "<tr><th>Su</th><th>Mo</th><th>Tu</th><th>We</th><th>Th</th><th>Fr</th><th>Sa</th></tr>";
$weeks=ceil($picked_month_length/7); //rounds upwards
$week=0; $wkday=0; //start the first week
for($week; $week <= $weeks; $week++)
{echo "<tr>";
for($wkday; $wkday<=6; $wkday++)
{
if($spacecounter<10) {
$compstring="$picked_comppart".'0'."$spacecounter";
} else {
$compstring="$picked_comppart$spacecounter";}
//echo "$compstring : $current_compstring<br>"; //DEBUG
// this version is for PAST DATE selection...no dates beyond today can be picked. (line 119)
if ($spacecounter < 1 ) {echo "<td align=center></td>";}
//elseif ($compstring < $current_compstring) {echo "<td align=center>n/a</td>"; echo "FUTURE DATES ONLY<BR>";} //future dates
//elseif ($compstring > $current_compstring) {echo "<td align=center>-</td>"; $week=$weeks;} //stops the cycle...no more rows needed // past dates only
elseif (($compstring==$current_compstring) AND ($compstring==$picked_date)) {echo "<td align=right bgcolor=red><font color=white>$spacecounter</font>
<input type=\"radio\" name=\"raw_date\" value=\"$picked_comppart$spacecounter\" class=\"puny_red\" checked>
</td>";}
elseif ($compstring==$current_compstring) {echo "<td align=right bgcolor=red><font color=white>$spacecounter</font>
<input type=\"radio\" name=\"raw_date\" value=\"$picked_comppart$spacecounter\" class=\"puny_red\">
</td>";}
elseif ($compstring==$picked_date) {echo "<td align=right bgcolor=blue><font color=white>$spacecounter</font>
<input type=\"radio\" name=\"raw_date\" value=\"$picked_comppart$spacecounter\" class=\"puny_blue\" checked>
</td>";}
elseif ($spacecounter > $picked_month_length) {echo "<td align=center></td>";}
else {echo "<td align=right bgcolor=yellow>$spacecounter
<input type=\"radio\" name=\"raw_date\" value=\"$picked_comppart$spacecounter\" class=\"puny_yellow\">
</td>";} // WEEKDAY SPACES
$spacecounter++;
}
echo "</tr>";
$wkday=0; //resets the row counter
}
echo "</table>";
//END calendar form based on picked date
echo "<input type=\"submit\" value=\"Save the date I clicked.\"></form>";
?>
</body></html>
Dang! I just noticed this version is not starting at the correct at the correct day when you click to go to different months....thought I had that part licked.
Back to the drawing board.