效果:
页面代码
年
季
月
时间段
至
JAVASCRIPT代码
function changeDisplay(obj)
{
var value = obj.value;
var html = "";
if(value=="time")
{
html = "至 ";
}
else if(value == "month")
{
html = getYearSelect()+" "+getMonthSelect();
}
else if(value == "stage")
{
html = getYearSelect()+" "+getStageSelect();
}
else if(value == "year")
{
html = getYearSelect();
}
document.getElementById("tdObj").innerHTML = html;
}
function getYearSelect()//获得年份下拉选择框
{
var m = new Date().getFullYear();
var n = m - 12;
if (n < 1000) n = 1000;
if (n + 14 > 9999) n = 9974;
var s = "";
var selectInnerHTML = s;
selectInnerHTML += "全部\r\n";
for (var i = n; i < n + 14; i++)
{
if (i == m)
{
selectInnerHTML += "" + i + "年" + "\r\n";
}
else
{
selectInnerHTML += "" + i + "年"