当前位置: 代码迷 >> ASP >> ,多谢
  详细解决方案

,多谢

热度:87   发布时间:2012-02-16 21:30:36.0
在线等,谢谢!
如下代码:通过选择的年,月,日,季自动填写日期。如果选择“年”,是要加上“L”,其它的不加。

现在情况是选择月,日,季度时,也会加上“L”,请指出错误?谢谢!


function getMyDate(o)
 {  
  var m = document.getElementById("m");
var l=document.getElementById("l").value; 
  var d = document.getElementById("d");
var r=document.getElementById("r").value; 
var s = o.options[o.selectedIndex].value;
   
 var n = new Date();


  if(s == "年") n.setYear(n.getYear() +parseInt(r)); n.setMonth(n.getMonth() +parseInt(l));
d.value = n.getYear() + "-" + (n.getMonth() +1) + "-" + n.getDate();

  if(s == "月") n.setMonth(n.getMonth() + parseInt(r));
  d.value = n.getYear() + "-" + (n.getMonth() +1) + "-" + n.getDate();

if(s == "季") n.setMonth(n.getMonth() + parseInt(r));
  d.value = n.getYear() + "-" + (n.getMonth() +1) + "-" + n.getDate();

if(s == "天") n.setMonth(n.getMonth() + parseInt(r));
  d.value = n.getYear() + "-" + (n.getMonth() +1) + "-" + n.getDate();


}

------解决方案--------------------
那你就在你的年的字符串后面连接一个字符串L就可以了
  相关解决方案