日期:2014-05-16  浏览次数:20375 次

js日历,利用Json传递数据,并附上日期显示

<%@ page language="java" contentType="text/html; charset=UTF-8"
??? pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
?<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" rev="stylesheet" href="../css/member.css" type="text/css" />
<style type="text/css">
*{margin:0;padding:0;font-size:12px;}
#div1{margin:20px;display:none;}
#div2{margin:20px;position:absolute; top:320px;}
#nowTime{width:285px;float:left;}
#nextTime{width:285px;float:left;margin:0 0 0 10px;}
.mytitle{width:100%;height:30px;background:#17a4eb;color:#FFFFFF;position:relative;}
.mytitle .c{text-align:center;line-height:30px;}
.mytitle .l{position:absolute;top:6px;left:5px;}
.mytitle .r{position:absolute;top:6px;right:5px;}
table.tcss{width:100%; background:#dee3e9;color:#9ea7ac;}
table.tcss tr{background:#f9fafc;}
table.tcss th{width:46px;padding:5px; font-size:11px;}
table.tcss td{padding:5px;text-align:center;}
.red{color:#ff0000;}
.myblue{color:#0000ff;
??? background-color:#39F;
??? }
.green{
??? background-color:#6F0;
}
table .tcss td p{color:#FF0000;}

input{margin:20px;}

a{TEXT-DECORATION:none}
</style>
<script type="text/javascript" src="<%=basePath %>script/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="<%=basePath %>script/jquery.corner.js"></script>
<script type="text/javascript">
$(function(){??? ??? ???
??? var aInput = document.getElementsByTagName('input');
??? var oDiv = document.getElementById('div1');
??? var oNowTime = document.getElementById('nowTime');
??? var oNextTime = document.getElementById('nextTime');???
???
??? var aTd = document.getElementsByTagName('td');
???
//??? alert(oTd.length);
??? var aNowSpan = oNowTime.getElementsByTagName('span');
??? var aNextSpan = oNextTime.getElementsByTagName('span');
???
//??? var bBtn = true;
//??? aInput[2].onclick=function(){
??? ??? var oDate = new Date();
//??? ???? if(bBtn){
??? ??? ??? oDiv.style.display='block';
??? ??? ??? if(oDate.getMonth()+1==12){
??? ??? ??? ??? showDate(oNowTime,oDate.getFullYear(),oDate.getMonth()+1,true);
??? ??? ??? ??? showDate(oNextTime,oDate.getFullYear()+1,1);
??? ??? ??? }else{
??? ??? ??? ??? showDate(oNowTime,oDate.getFullYear(),oDate.getMonth()+1,true);
??? ??? ??? ??? showDate(oNextTime,oDate.getFullYear(),oDate.getMonth()+2);
??? ??? ??? }
??? //??? ??? alert(oDate.getDate());
??? ??? ??? showColor(oDate.getDate());
??? ??? ??? showBtn();
??? ??? ??? hideLastTr();
??? ??? ??? getJson('nowTime');
??? ??? ??? getJson('nextTime');
/*??? ??? }else{
??? ??? ??? oDiv.style.display='none';
??? ??? }
*/??? ???
//??? ??? bBtn = !bBtn;
//??? };
???
??? function showDate(obj,year,month,bBtn){
??? ??? var oDate = new Date();
??? ??? var dayNum = 0;
??? ???
??? ??? //没有Date则创建
??? ??? if(!obj.bBtn){
??? ??? ??? obj.oTitle = document.createElement('div');
??? ??? ??? obj.oTitle.className='mytitle';
??? ??? ??? obj.appendChild(obj.oTitle);
??? ??? ???
??? ??? ??? var oTable = document.createElement('table');
??? ??? ??? $(oTable).addClass('tcss');
??? ??? ??? var oThead = document.createElement('thead');
??? ??? ???