Træk dato ud fra kalender popup
Hej eksperter..Jeg skal have lavet et system hvor en bruger skal vælge en dato i en formular.
Jeg har set op til flere steder at man kan lave en lille kalender der popper op, hvor man trykker på datoen og derved sætter den ind i et tekstfelt i formatet dd-mm-yyyy.
Jeg har en kalender liggende der måske kan bruges efter lidt tilretning:
<?
setlocale(LC_ALL,da_DK.ISO8859-1);
$Year = (isset($_REQUEST['Year']) && $_REQUEST['Year']) ? $_REQUEST['Year'] : strftime("%Y",$timeconf);
$Month = (isset($_REQUEST['Month']) && $_REQUEST['Month']) ? $_REQUEST['Month'] : strftime("%m",$timeconf);
$StartDate = "$Year-$Month-01";
$StartDateTS = strtotime($StartDate);
$StartDayNum = strftime("%u",$StartDateTS);
$LastDay = strftime("%e",strtotime("-1 day",strtotime("+1 month",$StartDateTS)));
$PreviousYear = strftime("%Y",strtotime("-1 month",$StartDateTS));
$PreviousMonth = strftime("%m",strtotime("-1 month",$StartDateTS));
$NextYear = strftime("%Y",strtotime("+1 month",$StartDateTS));
$NextMonth = strftime("%m",strtotime("+1 month",$StartDateTS));
echo("<table width=\"160\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class='caltext'>\n");
echo("<tr class='caltop'>\n");
echo("<td colspan=\"8\"><a href=\"".$_SERVER['SELF']."?Year=$PreviousYear&Month=$PreviousMonth\"><<</a> ".strftime("%B %Y",$StartDateTS)." <a href=\"".$_SERVER['SELF']."?Year=$NextYear&Month=$NextMonth\">>></a></td>\n");
echo("</tr>\n");
echo("<tr class='calday'>\n");
echo("<td width=\"20\" height=\"20\"> </td>\n");
echo("<td width=\"20\" style=\"border-bottom: 1px solid black\">M</td>\n");
echo("<td width=\"20\" style=\"border-bottom: 1px solid black\">T</td>\n");
echo("<td width=\"20\" style=\"border-bottom: 1px solid black\">O</td>\n");
echo("<td width=\"20\" style=\"border-bottom: 1px solid black\">T</td>\n");
echo("<td width=\"20\" style=\"border-bottom: 1px solid black\">F</td>\n");
echo("<td width=\"20\" style=\"border-bottom: 1px solid black\">L</td>\n");
echo("<td width=\"20\" style=\"border-bottom: 1px solid black\">S</td>\n");
echo("</tr>\n");
// LAV TOMME FELTER HVIS MÅNEDEN STARTER PÅ EN ANDEN DAG END MANDAG
if ($StartDayNum > 1) {
echo("<tr>\n");
echo("<td height=\"20\" align=\"right\" style=\"border-right: 1px solid black; padding-right: 5px\" class='calday'> ".date("W",$StartDateTS)."</td>\n");
$EmptyCells = $StartDayNum - 1;
for ($I = 0; $I < $EmptyCells; $I++) {
echo("<td class='caldatetd'> </td>\n");
}
}
for ($Day = 1; $Day <= $LastDay; $Day++) {
if (date("w",strtotime("$Year-$Month-$Day")) == 1) {
echo("</tr>\n");
echo("<tr>\n");
echo("<td height=\"20\" style=\"border-right: 1px solid black; padding-right: 5px\" class='calday'>".date("W",strtotime("$Year-$Month-$Day"))."</td>\n");
}
$roundDay = round(date("d"));
if($Day == $roundDay) {
echo("<td><a href=\"index.php?site=941&Year=".$_GET['Year']."&Month=".$_GET['Month']."&d=$Day&m=$Month&y=$Year\" class='caltoday'>$Day</a></td>\n");
} else {
echo("<td><a href=\"index.php?site=941&Year=".$_GET['Year']."&Month=".$_GET['Month']."&d=$Day&m=$Month&y=$Year\" class='caldate'>$Day</a></td>\n");
}
}
echo("</tr>\n");
echo("</table>\n");
?>
