EasyUI:年份、月份下拉框Demo

                                     

<td width="10%" height="25px" style="text-align:center;"><font style="font-size: 12px;">年度:</font></td>
<td width="15%" height="25px"  style="text-align: left;">
  <input id="yearChoose" name="yearChoose" class="easyui-combobox ui-text" type="text"  value="${yearChoose}" style="width:120px" />
</td>
<td width="10%" height="25px" style="text-align:center;"><font style="font-size: 12px;">月份:</font></td>
<td width="15%" height="25px"  style="text-align: left;">
  <input id="monthChoose" name="monthChoose" class="easyui-combobox ui-text" type="text"  value="${monthChoose}" style="width:120px" />
</td>

//年度下拉框初始化
$("#yearChoose").combobox({   
valueField:'year',    
textField:'year',  
panelHeight:'auto'
});
var data = [];//创建年度数组
var startYear;//起始年份
var thisYear=new Date().getUTCFullYear();//今年
var endYear=thisYear+1;//结束年份
//数组添加值(2012-2016)//根据情况自己修改
for(startYear=endYear-4;startYear<=thisYear;startYear++){ 
  data.push({"year":startYear});
}
$("#yearChoose").combobox("loadData", data);//下拉框加载数据
$("#yearChoose").combobox("setValue",thisYear);//设置默认值为今年
//月度下拉框初始化
$("#monthChoose").combobox({
valueField:'month',    
textField:'month',  
panelHeight:'auto',
editable:false
});
var data1 = [];//创建月份数组
var startMonth=1;//起始月份
var thisMonth=new Date().getUTCMonth()+1;//本月
//数组添加值(1-12月)为固定值
for(startMonth;startMonth<13;startMonth++){
  data1.push({"month":startMonth});
}
$("#monthChoose").combobox("loadData", data1);//下拉框加载数据
$("#monthChoose").combobox("setValue",thisMonth);//设置默认值为本月

EasyUI:年份、月份下拉框Demo

<td width="10%" height="25px" style="text-align:center;"><font style="font-size: 12px;">年度:</font></td>
<td width="15%" height="25px"  style="text-align: left;">
  <input id="yearChoose" name="yearChoose" class="easyui-combobox ui-text" type="text"  value="${yearChoose}" style="width:120px" />
</td>
<td width="10%" height="25px" style="text-align:center;"><font style="font-size: 12px;">月份:</font></td>
<td width="15%" height="25px"  style="text-align: left;">
  <input id="monthChoose" name="monthChoose" class="easyui-combobox ui-text" type="text"  value="${monthChoose}" style="width:120px" />
</td>
<td width="10%" height="25px" style="text-align:center;"><font style="font-size: 12px;">年度:</font></td>
<td width="15%" height="25px"  style="text-align: left;">
  <input id="yearChoose" name="yearChoose" class="easyui-combobox ui-text" type="text"  value="${yearChoose}" style="width:120px" />
</td>
<td width="10%" height="25px" style="text-align:center;"><font style="font-size: 12px;">月份:</font></td>
<td width="15%" height="25px"  style="text-align: left;">
  <input id="monthChoose" name="monthChoose" class="easyui-combobox ui-text" type="text"  value="${monthChoose}" style="width:120px" />
</td>

猜你喜欢

转载自blog.csdn.net/ya_101/article/details/84339636
今日推荐