MyDatePicker介绍及基本用法
一. MyDatePicker介绍及下载
介绍及下载官方网站:http://www.my97.net/dp/demo/index.htm
二. MyDatePicker案例
1) 用的Myeclipse10,新建一个Web Project工程,名为DateDemo。2) 在WebRoot目录下新建一个文件夹并命为js。时间控件解压后,将名为My97DatePicker的 文件夹 复制到js中。3) 为该工程配置Tomcat,tomcat版本随意。4) 引入该组件,在index.jsp的<head></head>之间添加如下代码:<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js" charset="utf-8"></script>5) 案例源代码
</pre><pre name="code" class="html">
</pre><pre name="code" class="html">
6) 启动tomcat,链接浏览器访问地址:http://localhost:8080/DateDemo/index.jsp<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <script type="text/javascript" src="js/My97DatePicker/WdatePicker.js" charset="utf-8"></script> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> This is my JSP page. <br> <br/> 基本用法: <input id="" class="Wdate" οnfοcus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})" /><br><br> 只能选择今天以前的日期: <input id="" class="Wdate" οnfοcus="WdatePicker({readOnly:true,maxDate:'%y-%M-%d'})" /><br><br> 使用运算表达式 只能选择 20小时前 至 30小时后 的日期 <input id="" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',minDate:'%y-%M-%d {%H-20}:%m:%s',maxDate:'%y-%M-%d {%H+30}:%m:%s'})" /><br><br> 开始,结束日期:<!-- $dp.$ 相当于 document.getElementById 函数. --> <input id="sdate" class="Wdate" οnfοcus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,maxDate:'#F{$dp.$D(\'edate\')}'})" /> - <input id="edate" class="Wdate" οnfοcus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,minDate:'#F{$dp.$D(\'sdate\')}',startDate:'#F{$dp.$D(\'sdate\',{d:+1})}'})" /><br><br> </body> </html>
7) 代码中WdatePicker配置。怎么配置就自由发挥了,参考如下:http://www.my97.net/dp/demo/resource/999.asp
注:html格式编码为UTF-8,避免中文显示出现乱码,部分代码参考其他文章。