JS日期选择器

在线演示: http://beansoft.java-cn.org/ajax/dateUtil/

下载: dateUtil.rar 9KB

用法代码:


<!-- 导入日历控件脚本 -->
<Script src="dateutil.js"></Script>

<form action="">
开始日期:
<SCRIPT language="JavaScript">
date = new Date();
year = date.getYear();
month = date.getMonth() + 1;
day = date.getDate();
// 改变月份和日期为两位
month = month + "";
day = day + "";
if(month.length == 1) month = "0" + month;
if(day.length == 1) day = "0" + day;
datestr = year+"-"+month+"-"+day;
// 用法:arrowtag('表单名', '日期字符串', '表单域长度');
arrowtag("beginDate",datestr,12);
</SCRIPT>

结束日期:
<SCRIPT language="JavaScript">
date = new Date();
year = date.getYear();
month = date.getMonth() + 1;
day = date.getDate();
// 改变月份和日期为两位
month = month + "";
day = day + "";
if(month.length == 1) month = "0" + month;
if(day.length == 1) day = "0" + day;
datestr = year+"-"+month+"-"+day;
// 用法:arrowtag('表单名', '日期字符串', '表单域长度');
arrowtag("endDate",datestr,12);
</SCRIPT>
<br/>
<input type=submit>
</form>



当然 datestr 也可以用 JSP 生成然后传送过去, 格式为"yyyy-MM-dd" 即可.

 

你可能感兴趣的:(JavaScript,Date,jsp,input,action,日历)