设为首页收藏本站

PHP.La 开源社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1137|回复: 4

求救!!JS获取当前日期 [复制链接]

Rank: 7Rank: 7Rank: 7

D-BOY 发表于 2010-4-26 12:34:38 |显示全部楼层
  1. <%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <script type="text/javascript" src="jquery-1.3.2.min.js"></script>

  7. <style type="text/css">
  8. body, p
  9. {
  10.         margin: 0;
  11. }

  12. body
  13. {
  14.         background-color: #FFF;
  15.         color: #000;
  16. }

  17. body, table
  18. {
  19.         font-family: "Verdana", "Arial", "Helvetica", "sans-serif";
  20.         font-size: 12px;
  21.         line-height: 150%;
  22. }

  23. input, select, textarea
  24. {
  25.         font-family: "Verdana", "Arial", "Helvetica", "sans-serif";
  26.         font-size: 12px;
  27. }



  28. A:link
  29. {
  30.         text-decoration: none;
  31.         color: #036;
  32. }
  33. A:visited
  34. {
  35.         text-decoration: none;
  36.         color: #036;
  37. }
  38. A:hover
  39. {
  40.         text-decoration: underline;
  41.         color: #F60;
  42. }

  43. A.menuChild:link
  44. {
  45.         text-decoration:none;
  46.         color:#036;
  47. }
  48. A.menuChild:visited
  49. {
  50.         text-decoration:none;
  51.         color:#036;
  52. }
  53. A.menuChild:hover
  54. {
  55.         text-decoration:underline;
  56.         color:#F60;
  57. }

  58. A.menuParent:link
  59. {
  60.         text-decoration:none;
  61.         color:#000;
  62. }
  63. A.menuParent:visited
  64. {
  65.         text-decoration:none;
  66.         color:#000;
  67. }
  68. A.menuParent:hover
  69. {
  70.         text-decoration:none;
  71.         color:#F60;
  72. }



  73. table.position
  74. {
  75.         width: 100%;
  76. }
  77. tr.position
  78. {
  79.         height: 25px;
  80.         background-color: #F4F7FC;
  81. }
  82. td.position
  83. {
  84.         padding-left: 20px;
  85.         border-right: 1px solid #ADCEFF;
  86.         border-bottom: 1px solid #ADCEFF;
  87. }


  88. table.listTable
  89. {
  90.         width: 98%;
  91.         background-color: #B1CEEE;
  92. }
  93. tr.listHeaderTr
  94. {
  95.         height: 25px;
  96.         background-color: #EBF4FD;
  97.         text-align: center;
  98.         font-weight: bold;
  99. }
  100. tr.listTr
  101. {
  102.         height: 25px;
  103.         background-color: #FFF;
  104.         text-align: center;
  105. }
  106. tr.listAlternatingTr
  107. {
  108.         height: 25px;
  109.         background-color: #FFFDF0;
  110.         text-align: center;
  111. }
  112. tr.listFooterTr
  113. {
  114.         height: 30px;
  115.         background-color: #EBF4FD;
  116.         text-align: center;
  117. }


  118. table.editTable
  119. {
  120.         width: 98%;
  121.         background-color: #B1CEEE;
  122. }
  123. tr.editHeaderTr
  124. {
  125.         height: 25px;
  126.         background-color: #EBF4FD;
  127. }
  128. td.editHeaderTd
  129. {
  130.         padding-left: 50px;
  131.         font-weight: bold;
  132. }
  133. tr.editTr
  134. {
  135.         height: 30px;
  136. }
  137. td.editLeftTd
  138. {
  139.         width: 150px;
  140.         text-align: center;
  141.         background-color: #FFFDF0;
  142. }
  143. td.editRightTd
  144. {
  145.         background-color: #FFF;
  146.         padding-left: 10px;
  147. }
  148. tr.editFooterTr
  149. {
  150.         height: 40px;
  151.         background-color: #EBF4FD;
  152. }
  153. td.editFooterTd
  154. {
  155.         padding-left: 150px;
  156. }
  157. </style>
  158. <script language="javascript">

  159. String.prototype.toDate = function(x, p) {
  160. if(x == null) x = "-";
  161. if(p == null) p = "ymd";
  162. var a = this.split(x);
  163. var y = parseInt(a[p.indexOf("y")]);
  164. //remember to change this next century ;)
  165. if(y.toString().length <= 2) y += 2000;
  166. if(isNaN(y)) y = new Date().getFullYear();
  167. var m = parseInt(a[p.indexOf("m")]) - 1;
  168. var d = parseInt(a[p.indexOf("d")]);
  169. if(isNaN(d)) d = 1;
  170. return new Date(y, m, d);
  171. }

  172. /**
  173. * 格式化<SPAN class=hilite1>日期</SPAN>
  174. * @param   d the delimiter
  175. * @param   p the pattern of your date
  176. * @author meizz
  177. */
  178. Date.prototype.format = function(style) {
  179. var o = {
  180.     "M+" : this.getMonth() + 1, //month
  181.     "d+" : this.getDate(),      //day
  182.     "h+" : this.getHours(),     //hour
  183.     "m+" : this.getMinutes(),   //minute
  184.     "s+" : this.getSeconds(),   //second
  185.     "w+" : "天一二三四五六".charAt(this.getDay()),   //week
  186.     "q+" : Math.floor((this.getMonth() + 3) / 3), //quarter
  187.     "S" : this.getMilliseconds() //millisecond
  188. }
  189. if(/(y+)/.test(style)) {
  190.     style = style.replace(RegExp.$1,
  191.     (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  192. }
  193. for(var k in o){
  194.     if(new RegExp("("+ k +")").test(style)){
  195.       style = style.replace(RegExp.$1,
  196.         RegExp.$1.length == 1 ? o[k] :
  197.         ("00" + o[k]).substr(("" + o[k]).length));
  198.     }
  199. }
  200. return style;
  201. };

  202. /**
  203. * 日历类
  204. * @param   beginYear 1990
  205. * @param   endYear   2010
  206. * @param   lang      0(中文)|1(英语) 可自由扩充
  207. * @param   dateFormatStyle "yyyy-MM-dd";
  208. * @version 2006-04-01
  209. * @author KimSoft (jinqinghua [at] gmail.com)
  210. * @update
  211. */
  212. function Calendar(beginYear, endYear, lang, dateFormatStyle) {
  213. this.beginYear = 1990;
  214. this.endYear = 2010;
  215. this.lang = 0;            //0(中文) | 1(英文)
  216. this.dateFormatStyle = "yyyy-MM-dd";

  217. if (beginYear != null && endYear != null){
  218.     this.beginYear = beginYear;
  219.     this.endYear = endYear;
  220. }
  221. if (lang != null){
  222.     this.lang = lang
  223. }

  224. if (dateFormatStyle != null){
  225.     this.dateFormatStyle = dateFormatStyle
  226. }

  227. this.dateControl = null;
  228. this.panel = this.getElementById("calendarPanel");
  229. this.form = null;

  230. this.date = new Date();
  231. this.year = this.date.getFullYear();
  232. this.month = this.date.getMonth();


  233. this.colors = {
  234. "cur_word"      : "#FFFFFF", //当日<SPAN class=hilite1>日期</SPAN>文字颜色
  235. "cur_bg"        : "#00FF00", //当日<SPAN class=hilite1>日期</SPAN>单元格背影色
  236. "sun_word"      : "#FF0000", //星期天文字颜色
  237. "sat_word"      : "#0000FF", //星期六文字颜色
  238. "td_word_light" : "#333333", //单元格文字颜色
  239. "td_word_dark" : "#CCCCCC", //单元格文字暗色
  240. "td_bg_out"     : "#EFEFEF", //单元格背影色
  241. "td_bg_over"    : "#FFCC00", //单元格背影色
  242. "tr_word"       : "#FFFFFF", //日历头文字颜色
  243. "tr_bg"         : "#666666", //日历头背影色
  244. "input_border" : "#CCCCCC", //input控件的边框颜色
  245. "input_bg"      : "#EFEFEF"   //input控件的背影色
  246. }

  247. this.draw();
  248. this.bindYear();
  249. this.bindMonth();
  250. this.changeSelect();
  251. this.bindData();
  252. }

  253. /**
  254. * 日历类属性(语言包,可自由扩展)
  255. */
  256. Calendar.language = {
  257. "year"   : [[""], [""]],
  258. "months" : [["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
  259.         ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]
  260.          ],
  261. "weeks" : [["日","一","二","三","四","五","六"],
  262.         ["SUN","MON","TUR","WED","THU","FRI","SAT"]
  263.          ],
  264. "clear" : [["清空"], ["CLS"]],
  265. "today" : [["今天"], ["TODAY"]],
  266. "close" : [["关闭"], ["CLOSE"]]
  267. }

  268. Calendar.prototype.draw = function() {
  269. calendar = this;

  270. var mvAry = [];
  271. mvAry[mvAry.length] = ' <form name="calendarForm" style="margin: 0px;">';
  272. mvAry[mvAry.length] = '    <table width="100%" border="0" cellpadding="0" cellspacing="1">';
  273. mvAry[mvAry.length] = '      <tr>';
  274. mvAry[mvAry.length] = '        <th align="left" width="1%"><input style="border: 1px solid ' + calendar.colors["input_border"] + ';background-color:' + calendar.colors["input_bg"] + ';width:16px;height:20px;" name="prevMonth" type="button" id="prevMonth" value="<" /></th>';
  275. mvAry[mvAry.length] = '        <th align="center" width="98%" nowrap="nowrap"><select name="calendarYear" id="calendarYear" style="font-size:12px;"></select><select name="calendarMonth" id="calendarMonth" style="font-size:12px;"></select></th>';
  276. mvAry[mvAry.length] = '        <th align="right" width="1%"><input style="border: 1px solid ' + calendar.colors["input_border"] + ';background-color:' + calendar.colors["input_bg"] + ';width:16px;height:20px;" name="nextMonth" type="button" id="nextMonth" value=">" /></th>';
  277. mvAry[mvAry.length] = '      </tr>';
  278. mvAry[mvAry.length] = '    </table>';
  279. mvAry[mvAry.length] = '    <table id="calendarTable" width="100%" style="border:0px solid #CCCCCC;background-color:#FFFFFF" border="0" cellpadding="3" cellspacing="1">';
  280. mvAry[mvAry.length] = '      <tr>';
  281. for(var i = 0; i < 7; i++) {
  282.     mvAry[mvAry.length] = '      <th style="font-weight:normal;background-color:' + calendar.colors["tr_bg"] + ';color:' + calendar.colors["tr_word"] + ';">' + Calendar.language["weeks"][this.lang][i] + '</th>';
  283. }
  284. mvAry[mvAry.length] = '      </tr>';
  285. for(var i = 0; i < 6;i++){
  286.     mvAry[mvAry.length] = '    <tr align="center">';
  287.     for(var j = 0; j < 7; j++) {
  288.       if (j == 0){
  289.         mvAry[mvAry.length] = ' <td style="cursor:default;color:' + calendar.colors["sun_word"] + ';"></td>';
  290.       } else if(j == 6) {
  291.         mvAry[mvAry.length] = ' <td style="cursor:default;color:' + calendar.colors["sat_word"] + ';"></td>';
  292.       } else {
  293.         mvAry[mvAry.length] = ' <td style="cursor:default;"></td>';
  294.       }
  295.     }
  296.     mvAry[mvAry.length] = '    </tr>';
  297. }
  298. mvAry[mvAry.length] = '      <tr style="background-color:' + calendar.colors["input_bg"] + ';">';
  299. mvAry[mvAry.length] = '        <th colspan="2"><input name="calendarClear" type="button" id="calendarClear" value="' + Calendar.language["clear"][this.lang] + '" style="border: 1px solid ' + calendar.colors["input_border"] + ';background-color:' + calendar.colors["input_bg"] + ';width:100%;height:20px;font-size:12px;"/></th>';
  300. mvAry[mvAry.length] = '        <th colspan="3"><input name="calendarToday" type="button" id="calendarToday" value="' + Calendar.language["today"][this.lang] + '" style="border: 1px solid ' + calendar.colors["input_border"] + ';background-color:' + calendar.colors["input_bg"] + ';width:100%;height:20px;font-size:12px;"/></th>';
  301. mvAry[mvAry.length] = '        <th colspan="2"><input name="calendarClose" type="button" id="calendarClose" value="' + Calendar.language["close"][this.lang] + '" style="border: 1px solid ' + calendar.colors["input_border"] + ';background-color:' + calendar.colors["input_bg"] + ';width:100%;height:20px;font-size:12px;"/></th>';
  302. mvAry[mvAry.length] = '      </tr>';
  303. mvAry[mvAry.length] = '    </table>';
  304. mvAry[mvAry.length] = ' </form>';
  305. this.panel.innerHTML = mvAry.join("");
  306. this.form = document.forms["calendarForm"];

  307. this.form.prevMonth.onclick = function () {calendar.goPrevMonth(this);}
  308. this.form.nextMonth.onclick = function () {calendar.goNextMonth(this);}

  309. this.form.calendarClear.onclick = function () {calendar.dateControl.value = "";calendar.hide();}
  310. this.form.calendarClose.onclick = function () {calendar.hide();}
  311. this.form.calendarYear.onchange = function () {calendar.update(this);}
  312. this.form.calendarMonth.onchange = function () {calendar.update(this);}
  313. this.form.calendarToday.onclick = function () {
  314.     var today = new Date();
  315.     calendar.date = today;
  316.     calendar.year = today.getFullYear();
  317.     calendar.month = today.getMonth();
  318.     calendar.changeSelect();
  319.     calendar.bindData();
  320.     calendar.dateControl.value = today.format(calendar.dateFormatStyle);
  321.     calendar.hide();
  322. }

  323. }

  324. //年份下拉框绑定数据
  325. Calendar.prototype.bindYear = function() {
  326. var cy = this.form.calendarYear;
  327. cy.length = 0;
  328. for (var i = this.beginYear; i <= this.endYear; i++){
  329.     cy.options[cy.length] = new Option(i + Calendar.language["year"][this.lang], i);
  330. }
  331. }

  332. //月份下拉框绑定数据
  333. Calendar.prototype.bindMonth = function() {
  334. var cm = this.form.calendarMonth;
  335. cm.length = 0;
  336. for (var i = 0; i < 12; i++){
  337.     cm.options[cm.length] = new Option(Calendar.language["months"][this.lang][i], i);
  338. }
  339. }

  340. //向前一月
  341. Calendar.prototype.goPrevMonth = function(e){
  342. if (this.year == this.beginYear && this.month == 0){return;}
  343. this.month--;
  344. if (this.month == -1) {
  345.     this.year--;
  346.     this.month = 11;
  347. }
  348. this.date = new Date(this.year, this.month, 1);
  349. this.changeSelect();
  350. this.bindData();
  351. }

  352. //向后一月
  353. Calendar.prototype.goNextMonth = function(e){
  354. if (this.year == this.endYear && this.month == 11){return;}
  355. this.month++;
  356. if (this.month == 12) {
  357.     this.year++;
  358.     this.month = 0;
  359. }
  360. this.date = new Date(this.year, this.month, 1);
  361. this.changeSelect();
  362. this.bindData();
  363. }

  364. //改变SELECT选中状态
  365. Calendar.prototype.changeSelect = function() {
  366. var cy = this.form.calendarYear;
  367. var cm = this.form.calendarMonth;
  368. for (var i= 0; i < cy.length; i++){
  369.     if (cy.options[i].value == this.date.getFullYear()){
  370.       cy[i].selected = true;
  371.       break;
  372.     }
  373. }
  374. for (var i= 0; i < cm.length; i++){
  375.     if (cm.options[i].value == this.date.getMonth()){
  376.       cm[i].selected = true;
  377.       break;
  378.     }
  379. }
  380. }

  381. //更新年、月
  382. Calendar.prototype.update = function (e){
  383. this.year = e.form.calendarYear.options[e.form.calendarYear.selectedIndex].value;
  384. this.month = e.form.calendarMonth.options[e.form.calendarMonth.selectedIndex].value;
  385. this.date = new Date(this.year, this.month, 1);
  386. this.changeSelect();
  387. this.bindData();
  388. }

  389. //绑定数据到月视图
  390. Calendar.prototype.bindData = function () {
  391. var calendar = this;
  392. var dateArray = this.getMonthViewArray(this.date.getYear(), this.date.getMonth());
  393. var tds = this.getElementById("calendarTable").getElementsByTagName("td");
  394. for(var i = 0; i < tds.length; i++) {
  395. //tds[i].style.color = calendar.colors["td_word_light"];
  396. tds[i].style.backgroundColor = calendar.colors["td_bg_out"];
  397.     tds[i].onclick = function () {return;}
  398.     tds[i].onmouseover = function () {return;}
  399.     tds[i].onmouseout = function () {return;}
  400.     if (i > dateArray.length - 1) break;
  401.     tds[i].innerHTML = dateArray[i];
  402.     if (dateArray[i] != "&nbsp;"){
  403.       tds[i].onclick = function () {
  404.         if (calendar.dateControl != null){
  405.           calendar.dateControl.value = new Date(calendar.date.getFullYear(),
  406.                                                 calendar.date.getMonth(),
  407.                                                 this.innerHTML).format(calendar.dateFormatStyle);
  408.         }
  409.         calendar.hide();
  410.       }
  411.       tds[i].onmouseover = function () {
  412.         this.style.backgroundColor = calendar.colors["td_bg_over"];
  413.       }
  414.       tds[i].onmouseout = function () {
  415.         this.style.backgroundColor = calendar.colors["td_bg_out"];
  416.       }
  417.       if (new Date().format(calendar.dateFormatStyle) ==
  418.           new Date(calendar.date.getFullYear(),
  419.                    calendar.date.getMonth(),
  420.                    dateArray[i]).format(calendar.dateFormatStyle)) {
  421.         //tds[i].style.color = calendar.colors["cur_word"];
  422.         tds[i].style.backgroundColor = calendar.colors["cur_bg"];
  423.         tds[i].onmouseover = function () {
  424.           this.style.backgroundColor = calendar.colors["td_bg_over"];
  425.         }
  426.         tds[i].onmouseout = function () {
  427.           this.style.backgroundColor = calendar.colors["cur_bg"];
  428.         }
  429.       }//end if
  430.     }
  431. }
  432. }

  433. //根据年、月得到月视图数据(数组形式)
  434. Calendar.prototype.getMonthViewArray = function (y, m) {
  435. var mvArray = [];
  436. var dayOfFirstDay = new Date(y, m, 1).getDay();
  437. var daysOfMonth = new Date(y, m + 1, 0).getDate();
  438. for (var i = 0; i < 42; i++) {
  439.     mvArray[i] = "&nbsp;";
  440. }
  441. for (var i = 0; i < daysOfMonth; i++){
  442.     mvArray[i + dayOfFirstDay] = i + 1;
  443. }
  444. return mvArray;
  445. }

  446. //扩展 document.getElementById(id) 多浏览器兼容性 from meizz tree source
  447. Calendar.prototype.getElementById = function(id){
  448. if (typeof(id) != "string" || id == "") return null;
  449. if (document.getElementById) return document.getElementById(id);
  450. if (document.all) return document.all(id);
  451. try {return eval(id);} catch(e){ return null;}
  452. }

  453. //扩展 object.getElementsByTagName(tagName)
  454. Calendar.prototype.getElementsByTagName = function(object, tagName){
  455. if (document.getElementsByTagName) return document.getElementsByTagName(tagName);
  456. if (document.all) return document.all.tags(tagName);
  457. }

  458. //取得HTML控件绝对位置
  459. Calendar.prototype.getAbsPoint = function (e){
  460. var x = e.offsetLeft;
  461. var y = e.offsetTop;
  462. while(e = e.offsetParent){
  463.     x += e.offsetLeft;
  464.     y += e.offsetTop;
  465. }
  466. return {"x": x, "y": y};
  467. }

  468. //显示日历
  469. Calendar.prototype.show = function (dateControl, popControl) {
  470. if (dateControl == null){
  471.     throw new Error("arguments[0] is necessary")
  472. }
  473. this.dateControl = dateControl;
  474. if (dateControl.value.length > 0){
  475. this.date = new Date(dateControl.value.toDate());
  476. this.year = this.date.getFullYear();
  477. this.month = this.date.getMonth();
  478.     this.changeSelect();
  479.     this.bindData();
  480. }
  481. if (popControl == null){
  482.     popControl = dateControl;
  483. }
  484. var xy = this.getAbsPoint(popControl);
  485. this.panel.style.left = xy.x + "px";
  486. this.panel.style.top = (xy.y + dateControl.offsetHeight) + "px";
  487. //this.setDisplayStyle("select", "hidden");
  488. this.panel.style.visibility = "visible";
  489. }

  490. //隐藏日历
  491. Calendar.prototype.hide = function() {
  492. this.setDisplayStyle("select", "visible");
  493. this.panel.style.visibility = "hidden";

  494. //下边这段代码用来计算两个日期相差的天数
  495. var sDate1 = document.all.dateCreatedStart.value;
  496. var sDate2 = document.all.dateCreatedStop.value;
  497.       var   aDate,   oDate1,   oDate2,   iDays  
  498.       aDate   =   sDate1.split("-")  
  499.       oDate1   =   new   Date(aDate[1]   +   '-'   +   aDate[2]   +   '-'   +   aDate[0])     //转换为3-1-2009格式  
  500.       aDate   =   sDate2.split("-")  
  501.       oDate2   =   new   Date(aDate[1]   +   '-'   +   aDate[2]   +   '-'   +   aDate[0])  
  502.       iDays   =   parseInt(Math.abs(oDate1   -   oDate2)   /   1000   /   60   /   60   /24)     //把相差的毫秒数转换为天数  
  503.     document.all.dateChangDu.value = iDays;
  504. //上边这段代码块用来计算两个日期相差的天数

  505. }

  506. //设置控件显示或隐藏
  507. Calendar.prototype.setDisplayStyle = function(tagName, style) {
  508. var tags = this.getElementsByTagName(null, tagName)
  509. for(var i = 0; i < tags.length; i++) {
  510.     if (tagName.toLowerCase() == "select" &&
  511.        (tags[i].name == "calendarYear" ||
  512.       tags[i].name == "calendarMonth")){
  513.       continue;
  514.     }
  515.     tags[i].style.visibility = style;
  516. }
  517. }

  518. document.write('<div id="calendarPanel" style="position: absolute;visibility: hidden;z-index: 9999;background-color: #FFFFFF;border: 1px solid #CCCCCC;width:175px;font-size:12px;"></div>');
  519. //var calendar = new Calendar();
  520. //调用calendar.show(dateControl, popControl);
  521. </script>
  522. <script language="JavaScript">
  523. // 计算两个日期的间隔天数
  524. function Computation(){   //sDate1和sDate2是2009-3-1格式  
  525. var sDate1 = document.all.dateCreatedStart.value;
  526. var sDate2 = document.all.dateCreatedStop.value;
  527.   var aDate, oDate1, oDate2, iDays  
  528.   aDate = sDate1.split("-")  
  529.   oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])   //转换为3-1-2009格式  
  530.   aDate = sDate2.split("-")  
  531.   oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])  
  532.   iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 /24)   //把相差的毫秒数转换为天数  
  533.   document.all.dateChangDu.value = iDays;
  534. }

  535. function CuDate(){
  536. var cuday = new Date();
  537.   date=cuday.getDate();
  538.   month=cuday.getMonth();
  539.   month=month+1;
  540.   if(month<=9)
  541.      month="0"+month;
  542.   year=today.getYear();
  543.   var nowDate=year+'-'+month+'-'+date;
  544.   document.getElementById("dateCreatedStart").value=nowDate;
  545.   }


  546. </script>
  547. </head>


  548. <body onload="Computation()">

  549. <jsp:include page="navigate.jsp"/></include>
  550. <form id="form1" onSubmit="form1_onsubmit() "name="form1" method="post" action="qingjia">

  551.   <tr>
  552.     <th width="681" height="94" scope="col">
  553.         <table width="811" border="0">
  554.       <tr>
  555.         <th width="60" height="94" scope="col">部门</th>
  556.         <th width="89" scope="col"><select name="bumen">
  557.                 <option  value="开发">开发</option>
  558.                 <option  value="测试">测试</option>
  559.                 <option  value="行政">行政</option>
  560.                 </select>
  561.         <th width="75" scope="col">姓名</th>
  562.         <th width="149" scope="col"><input type="text" name="name"></th>
  563.         <th width="135" scope="col">申请日期</th>
  564.         <th width="277" scope="col"><input type="text" name="Date" id="Date" size="31" style="margin:2px auto 2px auto;" value="" onclick="new Calendar().show(this);" readonly="true" /><br />
  565.       </tr>
  566.          
  567.     </table></th>
  568.   </tr>
  569.   <tr>
  570.   <hr />
  571.    
  572.     <td height="161"><p>请假类别
  573.         <select name="applytype">
  574.         <option  value="病假">病假</option>
  575.         <option  value="事假">事假</option>
  576.         <option  value="带薪休假">带薪休假</option>
  577.         <option  value="婚假">婚假</option>
  578.         <option  value="产假">病假</option>
  579.         <option  value="丧假">病假</option>
  580.         <option  value="其他">病假</option>
  581.         </select>
  582.         </p>
  583.        
  584.      (请说明):
  585.      <label>
  586.      <textarea name="reason"></textarea>
  587.      </label>
  588.        
  589.          
  590.         </td>
  591.   </tr>
  592.   <hr />
  593.   <tr>
  594.   
  595.     <td height="124"><p>请假时间:自
  596.         <input type="text" name="startYear" id="dateCreatedStart" size="31" style="ime-mode:disabled" onclick="new Calendar().show(this);" readonly="true" value=""/>
  597.           起/至
  598.     <input type="text" name="endYear" id="dateCreatedStop" size="31" style="ime-mode:disabled" onclick="new Calendar().show(this);" readonly="true" value=""  />
  599.           日 /总共
  600.           <label>
  601.           <input name="totalday" class="ttday" id="dateChangDu" value="" readonly="true"/>
  602.           </label>
  603.           天 </p>
  604.       <p>&nbsp;   </p>
  605.    
  606.         <label>申请人
  607.           <input type="text" name="appname" />
  608.         </label>
  609.      
  610.       <p>&nbsp;</p></td>
  611.   </tr>
  612.   <hr />
  613.   <tr>
  614.     <td height="123"><table width="913" height="140" border="0">
  615.       <tr>
  616.         <th width="387" scope="col">
  617.           <label>部门主管意见
  618.             <textarea name="suggest" rows="10"></textarea>
  619.             </label>
  620.                         <p></p>
  621.   
  622.          
  623.             <label><br />
  624.             签名
  625.               <input type="text" name="csignature" />
  626.             </label>
  627.             <label><br />
  628.             日期
  629.             <input type="text" name="zhuDate" id="zhuDate" size="31" style="margin:2px auto 2px auto;" value="" onclick="new Calendar().show(this);" readonly="true" />
  630.             </label>
  631.                        
  632.          
  633.           </th>
  634.         <th width="516" scope="col"><p>行政部门备案:</p>
  635.           <p>年休假:已休 天;(10天)</p>
  636.           <p>病 假:已休 天;(5天)</p>
  637.           <p>事 假:已休 天;</p>
  638.           <p>婚 假:已休 天; (3天/15天)</p>
  639.           <p>调休假:已休 天. (可休 天)</p>
  640.          
  641.             <label>经办人签名
  642.               <input type="text" name="psignature" />
  643.             </label>
  644.       
  645.           <p>&nbsp; </p>
  646.           <p>&nbsp;</p></th>
  647.       </tr>
  648.     </table></td>
  649.   </tr>
  650.   <hr />
  651.   <tr>
  652.     <td height="156"><p>备注:</p>
  653.     <p> 5天(含)以下假期,提前3个工作日,由部门主管审批;5天以上假期,提前5个工作日,由总经理复审同意.</p>
  654.     <p>病假3天及3天以上时,应同时提交正规医院开具的病情证明及病假单. </p>
  655.     <p>&nbsp; </p>
  656.    
  657.       <label>
  658.       <input type="submit" name="Submit" value="提交" />
  659.         </label>
  660.     </form>
  661.     </td>
  662.   </tr>

  663. </body>
  664. </html>
复制代码
我想在页面打开市在那几个要填日期的空格里直接显示着当前日期,怎么操作呢
地狱不空,誓不成佛

Rank: 7Rank: 7Rank: 7

D-BOY 发表于 2010-4-26 12:44:35 |显示全部楼层
function CuDate(){
var cuday = new Date();
  date=cuday.getDate();
  month=cuday.getMonth();
  month=month+1;
  if(month<=9)
     month="0"+month;
  year=cuday.getYear();
  var nowDate=year+'-'+month+'-'+date;
  document.getElementById("dateCreatedStart").value=nowDate;
  }

<body onload="CuDate()">
地狱不空,誓不成佛

使用道具 举报

Rank: 9Rank: 9Rank: 9

╃巡洋艦㊣ 发表于 2010-4-26 12:45:56 |显示全部楼层
这样也把时间数据格式化了,挺不错啊!
要承担起对事业的责任,首先必须要有坚强的自信心,要始终自信做任何事情都能成功,绝对能够成功!

使用道具 举报

Rank: 7Rank: 7Rank: 7

D-BOY 发表于 2010-4-26 12:48:00 |显示全部楼层
这样也把时间数据格式化了,挺不错啊!
╃巡洋艦㊣ 发表于 2010-4-26 12:45



    额,抄的,先前有个变量名字改错了,显示不出来,就提问了
地狱不空,誓不成佛

使用道具 举报

Rank: 2

偌遥 发表于 2011-1-6 11:38:47 |显示全部楼层
不错呢 强大~~

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|PHP.La 开源社区 ( 京ICP备09104811号 )  

GMT+8, 2012-5-20 12:11

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部