Click to See Complete Forum and Search --> : A SIMPLE javascript date picker! HOORAY! But...


Joseph Sliker
05-20-2009, 05:10 PM
Hi; I've FINALLY found a javascript date chooser that seems simple enough for me to comprehend and use, but I could use still use a wee bit of help, maybe someone here is familiar with it/can help me with a couple of tweaks?

It is John Hansen's (yellow5) DateChooser 2.0

http://yellow5.us/projects/datechooser

It seems really small and clean and does not mess up the display or functions of my pages too much, but it does not seem to be well documented and I can't seem to get the date limitation settings to work properly (ie. If I only want to allow the user to select dates from the past or dates into the future.

Here is a very stripped down version of what I have so far...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>DateChooser Demo</title>
<link rel="stylesheet" type="text/css" media="all" href="datechooser.css">
<script type="text/javascript" src="datechooser.js"></script>
<script type="text/javascript">
<!-- //
events.add(window, 'load', WindowLoad);
function FunctionEx6(objDate)
{
ndExample5.DateChooser.updateFields();
return true;
}
// -->
</script>
</head>
<body>
<?php
foreach($_POST as $key=>$value) {
$$key=$value;
echo "$key: $value<br>"; // debug
}

echo " <div id=\"container\">
<form method=\"POST\" action=\"mytest.php\" target=\"_self\">";
$datedefault=date('mdY'); //put this in the date box to save users unneed step if data is current/today.
$dateselected=date('Y-m-d'); //start with this as default value
ECHO "
<input
name=ANYDATE
id=\"datechooserexA\"
class=\"datechooser
dc-dateformat='Y-m-d'
dc-iconlink='datechooser.png'
dc-startdate=$datedefault
dc-onupdate='FunctionEx6'
\"
size=\"8\"
type=\"text\"
value=\"$dateselected\">ANYDATE<br>
"; // NO dc-earliestdate or latestdate

ECHO "
<input
name=PASTDATE
id=\"datechooserexB\"
class=\"datechooser
dc-dateformat='Y-m-d'
dc-iconlink='datechooser.png'
dc-startdate=$datedefault
dc-latestdate=$datedefault
dc-onupdate='FunctionEx6'
\"
size=\"8\"
type=\"text\"
value=\"$dateselected\">PASTDATE<br>
"; // PROBLEM: Calendar does not limit to current/past dates.

ECHO "
<input
name=FUTUREDATE
id=\"datechooserexC\"
class=\"datechooser
dc-dateformat='Y-m-d'
dc-iconlink='datechooser.png'
dc-startdate=$datedefault
dc-earliestdate=$datedefault
dc-onupdate='FunctionEx6'
\"
size=\"8\"
type=\"text\"
value=\"$dateselected\">FUTUREDATE<br>
"; // PROBLEM: Calendar does not limit to current/future dates.

echo "<input type=\"submit\" value=\"Submit Dates\"></form>";
?>
</div>
</body>
</html>
...overall this is real close to what I need, but I'd like to solve what's going on with the date limiting functions.

...I also would not mind if the little calendar pages would just be open or displayed when the form loads rather than requiring a click.

Thanks for any input.

Joseph Sliker
05-20-2009, 05:35 PM
Dang single quote marks got me again!

dc-startdate=$datedefault
dc-earliestdate=$datedefault

should be... dc-startdate='$datedefault'
dc-earliestdate='$datedefault'

...Now the date-limited versions of the calendar work great.

I'd still like to just see these calendars open and ready to go though....if anyone has a suggestion for that.