drop down met datum
ik zoek eigenlijk een scriptje wat een drop-down-menu maakt met daarin de data van de afgelopen 4 weken (beginnend bij de huidige dag). Iemand die zoiets heeft liggen? Of misschien weet hoe zoiets in elkaar gezet kan worden?
Bedankt voor de moeite alvast,
Martijn
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
function DateDropDown($size=30,$default="DropDate") {
// $size = the number of days to display in the drop down
// $default = Todays date in m:d:Y format (SEE DATE COMMAND ON WWW.PHP.NET)
// $skip = if set then the program will skip Sundays and Saturdays
$skip=0;
echo "<select name=$default STYLE=\"font-family: monospace;\">\n";
for ($i = 0; $i <= $size; $i++) {
$theday = mktime (0,0,0,date("m") ,date("d")+$i ,date("Y"));
$option=date("D M j, Y",$theday);
$value=date("m:d:Y",$theday);
$dow=date("D",$theday);
if ($dow=="Sun") {
echo "<option disabled> </option>\n";
}
if ($value == $default) {
$selected="SELECTED";
} else {
$selected="";
}
if (($dow!="Sun" and $dow!="Sat") or !$skip) {
echo "<option value=\"$value\" $selected>$option</option>\n";
}
}
echo "</select>\n";
}
//If the date is there because the SUBMIT button was pushed then print it
//You probably should use $_POST['dropdate'] in the if statment below but.....
if ($dropdate != "") {
echo "The date returned from the control is: " . $dropdate;
}
echo "<form>\n";
DateDropDown(30,"dropdate");
echo "<input type=submit>\n";
echo "</form>\n";
?>
function DateDropDown($size=30,$default="DropDate") {
// $size = the number of days to display in the drop down
// $default = Todays date in m:d:Y format (SEE DATE COMMAND ON WWW.PHP.NET)
// $skip = if set then the program will skip Sundays and Saturdays
$skip=0;
echo "<select name=$default STYLE=\"font-family: monospace;\">\n";
for ($i = 0; $i <= $size; $i++) {
$theday = mktime (0,0,0,date("m") ,date("d")+$i ,date("Y"));
$option=date("D M j, Y",$theday);
$value=date("m:d:Y",$theday);
$dow=date("D",$theday);
if ($dow=="Sun") {
echo "<option disabled> </option>\n";
}
if ($value == $default) {
$selected="SELECTED";
} else {
$selected="";
}
if (($dow!="Sun" and $dow!="Sat") or !$skip) {
echo "<option value=\"$value\" $selected>$option</option>\n";
}
}
echo "</select>\n";
}
//If the date is there because the SUBMIT button was pushed then print it
//You probably should use $_POST['dropdate'] in the if statment below but.....
if ($dropdate != "") {
echo "The date returned from the control is: " . $dropdate;
}
echo "<form>\n";
DateDropDown(30,"dropdate");
echo "<input type=submit>\n";
echo "</form>\n";
?>
een erg simpele aanpassing in bovenstaand script
:P
Gewijzigd op 17/06/2004 15:36:00 door tineau