请教各位,在html中,如果用js或jquery 生成从指定时间以来的:年、季度、月份的下拉列表
如:从2009年1月至今的 年度、季度、月份下拉列表<select name="select_mouth" id="select_mouth" onchange="window.open(this.options[this.selectedIndex].value,target='_self')">
<option> 按月份查看 </option>
<option value="2009-1"> 2009年 1月份</option>
<option value="2009-2"> 2009年 2月份</option>
<option value="2009-3"> 2009年 3月份</option>
<option value="2009-4"> 2009年 4月份</option>
<option value="2009-5"> 2009年 5月份</option>
<option value="2009-6"> 2009年 6月份</option>
<option value="2009-7"> 2009年 7月份</option>
<option value="2009-8"> 2009年 8月份</option>
<option value="2009-9"> 2009年 9月份</option>
<option value="2009-10"> 2009年 10月份</option>
<option value="2009-11"> 2009年 11月份</option>
<option value="2009-12"> 2009年 12月份</option>
<option value="2010-1"> 2010年 1月份</option>
<option value="2010-2"> 2010年 2月份</option>
<option value="2010-3"> 2010年 3月份</option>
<option value="2010-4"> 2010年 4月份</option>
<option value="2010-5"> 2010年 5月份</option>
</option>
</select><select name="select_year" id="select_year" onchange="window.open(this.options[this.selectedIndex].value,target='_self')">
<option> 按年度查看 </option>
<option value="2009"> 2009年 </option>
<option value="2010"> 2010年 </option>
</option>
</select><select name="select_season" id="select_season" onchange="window.open(this.options[this.selectedIndex].value,target='_self')">
<option> 按季度查看 </option>
<option value="2009-1"> 2009年 1季度</option>
<option value="2009-4"> 2009年 2季度</option>
<option value="2009-7"> 2009年 3季度</option>
<option value="2009-10"> 2009年 4季度</option>
<option value="2010-1"> 2010年 1季度</option>
<option value="2010-4"> 2010年 2季度</option>
</option>
</select>望高手赐教,谢谢
如:从2009年1月至今的 年度、季度、月份下拉列表<select name="select_mouth" id="select_mouth" onchange="window.open(this.options[this.selectedIndex].value,target='_self')">
<option> 按月份查看 </option>
<option value="2009-1"> 2009年 1月份</option>
<option value="2009-2"> 2009年 2月份</option>
<option value="2009-3"> 2009年 3月份</option>
<option value="2009-4"> 2009年 4月份</option>
<option value="2009-5"> 2009年 5月份</option>
<option value="2009-6"> 2009年 6月份</option>
<option value="2009-7"> 2009年 7月份</option>
<option value="2009-8"> 2009年 8月份</option>
<option value="2009-9"> 2009年 9月份</option>
<option value="2009-10"> 2009年 10月份</option>
<option value="2009-11"> 2009年 11月份</option>
<option value="2009-12"> 2009年 12月份</option>
<option value="2010-1"> 2010年 1月份</option>
<option value="2010-2"> 2010年 2月份</option>
<option value="2010-3"> 2010年 3月份</option>
<option value="2010-4"> 2010年 4月份</option>
<option value="2010-5"> 2010年 5月份</option>
</option>
</select><select name="select_year" id="select_year" onchange="window.open(this.options[this.selectedIndex].value,target='_self')">
<option> 按年度查看 </option>
<option value="2009"> 2009年 </option>
<option value="2010"> 2010年 </option>
</option>
</select><select name="select_season" id="select_season" onchange="window.open(this.options[this.selectedIndex].value,target='_self')">
<option> 按季度查看 </option>
<option value="2009-1"> 2009年 1季度</option>
<option value="2009-4"> 2009年 2季度</option>
<option value="2009-7"> 2009年 3季度</option>
<option value="2009-10"> 2009年 4季度</option>
<option value="2010-1"> 2010年 1季度</option>
<option value="2010-4"> 2010年 2季度</option>
</option>
</select>望高手赐教,谢谢
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
//<![CDATA[
var $startime=new Date('2009/1/1 0:00:00');
var $now=new Date();
var $m,$y,$s;
function mkselect(year,month){
$m=('#select_mouth');
$y=('#select_year');
$s=('#select_season');
month++;
$("<option></option>").val(year+'-'+month).text(year+'年'+month+'月').appendTo($m);
if((month%3)==1){
$("<option></option>").val(year+'-'+month).text(year+'年'+Math.ceil(month/3)+'季度').appendTo($s);
}
}
$(function(){
$m=('#select_mouth');
$y=('#select_year');
$s=('#select_season');
for(var $year=$startime.getFullYear(),$maxyear=$now.getFullYear();$year<=$maxyear;$year++){
if($startime.getFullYear()<$now.getFullYear()){
if($year<$maxyear){
for(var $month=$startime.getMonth();$month<=11;$month++){mkselect($year,$month)}
}else{
for(var $month=0;$month<=$now.getMonth();$month++){mkselect($year,$month)}
}
}else{
for(var $month=$startime.getMonth();$month<=$now.getMonth();$month++){mkselect($year,$month)}
}
$("<option></option>").val($year).text($year+'年').appendTo($y);
}
})
//]]>
</script></head>
<body>
<select name="select_mouth" id="select_mouth" onchange="window.open(this.options[this.selectedIndex].value,'_self')">
<option>按月份查看</option>
</select>
<select name="select_year" id="select_year" onchange="window.open(this.options[this.selectedIndex].value,'_self')">
<option>按年度查看</option>
</select>
<select name="select_season" id="select_season" onchange="window.open(this.options[this.selectedIndex].value,'_self')">
<option>按季度查看</option>
</select>
</body>
</html>