标签:
功能需求:页面主要有两个日历框,一个是当前日期,一个是去年同期,要求当用户改变当前日期时,同步修改去年同期为当前日期-1年。
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <%@ taglib prefix="s" uri="/struts-tags"%> 3 <%@ taglib uri="/struts-dojo-tags" prefix="sx"%> 4 <% 5 String path = request.getContextPath(); 6 String basePath = request.getScheme() + "://" 7 + request.getServerName() + ":" + request.getServerPort() 8 + path + "/"; 9 %> 10 11 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 12 <html> 13 <head> 14 <base href="<%=basePath%>"> 15 16 <title>九地市无线话务量查询</title> 17 18 <meta http-equiv="pragma" content="no-cache"> 19 <meta http-equiv="cache-control" content="no-cache"> 20 <meta http-equiv="expires" content="0"> 21 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 22 <meta http-equiv="description" content="This is my page"> 23 <sx:head /> 24 <script type="text/javascript" language="javascript"> 25 //日期选择框同步 26 function synchronizeDate() { 27 var date = new Date(dojo.widget.byId("nowDay").getValue()); 28 var year = date.getFullYear(); 29 date.setYear(year - 1); 30 dojo.widget.byId("pastDay").setValue(date); 31 } 32 dojo.event.topic.subscribe("/value", synchronizeDate); 33 </script> 34 /head> 35 <body> 36 <sx:datetimepicker id="nowDay" name="now" label="当前日期" value="#request.now" displayFormat="yyyy-MM-dd" valueNotifyTopics="/value" /> 37 <sx:datetimepicker id="pastDay" name="yesteryear" label="去年同期" value="#request.yesteryear" displayFormat="yyyy-MM-dd" /> 38 </body>
使用JS控制struts的日期控件datetimepicker
标签:
原文地址:http://www.cnblogs.com/fange666/p/4670702.html