日期联动菜单
功能:自动识别大小月闰平年,无刷新。
----------selectDate.php---------------------------------------------------------
———— PHP代码 ————
<SELECT NAME="year" ONCHANGE="document.all.modifyDay.src = 'day.php?d=' + this.value + document.all.month.value">
<?php
for($x=2000;$x<2011;$x++)
echo "<OPTION value='$x'>$x</OPTION>";
?>
</SELECT>
年
<SELECT NAME="month" ONCHANGE="document.all.modifyDay.src = 'day.php?d=' + document.all.year.value + this.value">
<?php
for($x=1;$x<13;$x++)
echo "<OPTION value='$x'>$x</OPTION>";
?>
</SELECT>
月
<SELECT name="day">
<?php
for($x=1;$x<29;$x++)
echo "<OPTION value='$x'>$x</OPTION>";
?>
</SELECT>日
<SCRIPT LANGUAGE="JAVASCRIPT" ID="modifyDay">
document.all.modifyDay.src = 'day.php?d=' + document.all.year.value + document.all.month.value;
</script>
————————————
---------------day.php---------------------------------
———— PHP代码 ————
<?php
$d = $_GET['d'];
$y = 29;
while(checkdate(substr($d,4,2),$y,substr($d,0,4)))
$y ++;
$y --;
echo "document.all.day.length=". $y .";";
for($x = 29; $x < $y + 1; $x ++)
{
$k = $x - 1;
echo "document.all.day.options[".$k."].value=".$x.";";
echo "document.all.day.options[".$k."].text =".$x.";";
}
?>
————————————
------------------------chinaboy-------------------------------------------------
[ Last edited by chinaboy at 08:25 on 2004-06-13 ]
--------------------------