标题:在 ASP 中对日期进行加运算后,出现: NaN-NaN-NaN 值
只看楼主
lzlzlxd
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2014-12-2
结帖率:0
已结贴  问题点数:10 回复次数:1 
在 ASP 中对日期进行加运算后,出现: NaN-NaN-NaN 值
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<script   language="JavaScript">                 
  <!--   Begin                  
  var   enable=0;                 
  today=new   Date();                 
  var   day;                 
  var   date;                 
  var   time_start   =   new   Date();                 
  var   clock_start   =   time_start.getTime();                 
  if(today.getDay()==0)     day="星期日"                 
  if(today.getDay()==1)     day="星期一"                 
  if(today.getDay()==2)     day="星期二"                 
  if(today.getDay()==3)     day="星期三"                 
  if(today.getDay()==4)     day="星期四"                 
  if(today.getDay()==5)     day="星期五"                 
  if(today.getDay()==6)     day="星期六"                 
  date=(today.getYear())+"年"+(today.getMonth()+1)+"月"+today.getDate()+"日   ";                 
  document.write("<span   style='font-size:   9pt;color:#000000;'>"+date);                 
  document.write(day+"</font></span>");                 
  //   -->                 
  </script>
<script language="JavaScript">
function autoje(){
    if (form1.days.value==0)
    {alert("请输入天数!");form1.days.focus();return;}
    if (isNaN(form1.days.value))
    {alert("您输入的不是有效值(请输入0-9之间的数)!");form1.days.focus();return;}
    ;}
    </script>
<script language="JavaScript">//在原有的日期中先加10天,然后date2输出加10天后的日期
    function changeDate() {
    var offset = form1.days.value;
    var dateStrA = form1.date1.value;
    var year = dateStrA.substring(0,4);
    var month = Number(dateStrA.substring(5,7))-1;
    var date = Number(dateStrA.substring(8,10))+offset;
    var dateB = new Date();
         dateB.setFullYear(year,month,date);
    var year2 = dateB.getFullYear();
    var month2 = (dateB.getMonth()+1)+"";
    var date2 = dateB.getDate()+"";
    if (month2.length == 1) month2 = "0"+month2;
    if (date2.length == 1) date2 = "0"+date2;
        form1.date2.value = year2 + "-" + month2 + "-" + date2;}
    </script>
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
  <p>a
    <label>
    <input name="date1" type="text" id="date1" />
    </label>
  </p>
  <p>b
    <label>
    <input name="days" type="text"  id="days" onblur="changeDate()" size="13" onkeyup="if(event.keycode==13){changeDate()}" />
    </label>
</p>
  <p>
    <label>
    <input name="date2" type="text" id="date2" />
    </label>
  </p>
  <p>
    <label>
    <input type="submit" name="Submit" value="提交" />
    </label>
  </p>
</form>
</body>
</html>
但是运行后DATE2出现:NaN-NaN-NaN
请帮查看原因。
搜索更多相关主题的帖子: PUBLIC enable 
2014-12-03 11:59
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
得分:10 
浏览器兼容问题?ie11测试后无问题
2014-12-05 11:37



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-439507-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.832246 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved