两个html控件,一个下拉列表框, 一个lebal
下拉列表框中提供用户三个选择,从当前时间开始的连续三个月份。
例如当前时间为2010年1月,则下拉列表中供选择的项有2010年1月 2010年2月
2010年3月。
后面的lebal显示的日前随着用户选择下拉列表日期的变化而变化,时间间隔为3个月
例如用户选择2010年1月 则lebal显示2010年4月
用户如果选择2010年2月 则lebal显示2010年5月
求详细javascript处理方法,不胜感激。急。
下拉列表框中提供用户三个选择,从当前时间开始的连续三个月份。
例如当前时间为2010年1月,则下拉列表中供选择的项有2010年1月 2010年2月
2010年3月。
后面的lebal显示的日前随着用户选择下拉列表日期的变化而变化,时间间隔为3个月
例如用户选择2010年1月 则lebal显示2010年4月
用户如果选择2010年2月 则lebal显示2010年5月
求详细javascript处理方法,不胜感激。急。
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head> <body>
<span id="content"></span>
<span id="info"></span>
<script type="text/javascript">
function chaLabel(val) {
document.getElementById('info').innerHTML = new Date().getFullYear() + '年' + val + '月';
}
!function(){
var o = document.getElementById('content');
var m = n = new Date().getMonth() + 1;
var html = '<select id="dsel" onchange="chaLabel(this.value)">';
for(var i = 0; i < 3; i++) {
html += '<option value=' + (m++) + '>' + (n++) + '</option>';
}
html += '</select>'
o.innerHTML = html;
}();
</script>
</body>
</html>
个人觉得在服务端取出时间构建下拉列表
再使用javascript取出用户所选择的时间,计算出3个月后的时间显示在label中