欢迎光临
我们一直在努力

送各位一个节日礼物–日期选择器(和ACTIVEX一样酷!原创)

建站超值云服务器,限时71元/月

————-date.html

<html>
<style>
input{font-family: "宋体"; font-size:9pt;height:15px;border:0px black solid;background:#f0f0f0;cursor:hand;background:none}
td{font-family: "宋体"; font-size:9pt;}
select{font-family: "宋体"; font-size:9pt;}
.input1{font-family: "宋体"; font-size:9pt;height:18px;line-height: 12pt;border:1px black solid;background:#e0e0e0}
</style>
<script language="javascript">
function checkinput()
  {
  while (isnan(document.all.years.value) || (document.all.years.value==" "))
    {
    document.all.years.value=years.value.substring(0,years.value.length-1)
    }
  }

function numberofdays(month,year)
  {
  var numdays=new array(31,28,31,30,31,30,31,31,30,31,30,31)
  n=numdays[month]
  
  if (month==1&&year%4==0) ++n
  
  return n
  }

function displaydates(day,month,year,shade){
  d=new date(year,month,1)
  var startday=d.getday()
  var numdays=numberofdays(month,year)
  var numrows=math.ceil((numdays+startday)/7)

  var tmps=""
  if((numdays+startday)%7>1) ++numrows
  var currentdate=0
  
       
  tmps="<table border=0 cellpadding=0 cellspacing=0><tr><td align=center>日</td><td align=center>一</td><td align=center>二</td><td align=center>三</td><td align=center>四</td><td align=center>五</td><td align=center>六</td></r>"
  for (var i=0;i<numrows;++i)
    {
    tmps=tmps+"<tr>"
    for(var j=0;j<7;++j){
    
     if (shade&&day==currentdate&&currentdate<numdays&&i*7+j>=startday)
       tmps=tmps+"<td bgcolor=#cccccc style=border:1px solid #909090>"
       else tmps=tmps+"<td>"
     if(currentdate>=numdays) tmps=tmps+" "
       else if(currentdate>0){
        ++currentdate
        tmps=tmps+writedate(currentdate)
        } else if(i*7+j>=startday){
        ++currentdate
        tmps=tmps+writedate(currentdate)
        }else tmps=tmps+" "
     tmps=tmps+"</td>"
     }
    tmps=tmps+"</tr>"
    }
  tmps=tmps+"</table>"
  return tmps
  }
          
function writedate(n){
return "<input type=button value="+n.tostring()+" style=width:20 onclick=setvalue("+n.tostring()+")>"
}

function setvalue(n)
  {
  document.all.dates.value=document.all.years.value+"-"+document.all.months.value+"-"+n
  document.all.days.value=n.tostring()
  datesbox.style.visibility="hidden"
  }

function showdates()
  {

  if ((event.x+150)>document.body.offsetwidth )
    datesbox.style.left=event.x+document.body.scrollleft-150
    else
    datesbox.style.left=event.x+document.body.scrollleft
  if ((event.y+165)>document.body.offsetheight )  
    datesbox.style.top=event.y+document.body.scrolltop-165
    else
    datesbox.style.top=event.y+document.body.scrolltop
  if (datesbox.style.visibility=="visible")
    datesbox.style.visibility="hidden"
    else
    datesbox.style.visibility="visible"
  yearadd(0)
  }

function showdates2()
  {
  if (datesbox.style.visibility=="visible")
    datesbox.style.visibility="hidden"
    }
  
function changeit(d,m,y)
  {
  daysin.innerhtml=displaydates(d,m-1,y,true)
  }
  
function yearadd(n)
  {
  years.value=(eval(years.value)+n).tostring()

  changeit(eval(days.value)-1,eval(months.value),eval(years.value))
  }
  
</script>

<body style="font-size:9pt">
<div id="datesbox" style="border:1px solid #c0c0c0;padding:5px 5px 5px 5px;background:#f0f0f0;height:165px; left: 50px; position: absolute; top: 31px; visibility: hidden; width: 150px"  ondblclick=showdates2()>
        <table border=0 cellspacing=0 cellpadding=0><tr><td rowspan=2 align="center"> <input type="hidden" size="2" name="days" value=""><select name="months" onchange="changeit(eval(days.value)-1,eval(months.value),eval(years.value))" style="length:320"><option value=1 selected
>一月</option>
        <option value=2>二月</option>
        <option value=3>三月</option>
        <option value=4>四月</option>
        <option value=5>五月</option>
        <option value=6>六月</option>
        <option value=7>七月</option>
        <option value=8>八月</option>
        <option value=9>九月</option>
        <option value=10>十月</option>
    <option value=11>十一月</option>
        <option value=12>十二月</option>
        </select></td><td rowspan=2 style="padding-right:1px"> <input name="years" size=4 value="0" class="input1" onkeyup="checkinput();changeit(eval(days.value),eval(months.value),eval(years.value))" onblur="checkinput()" maxlength=4></td><td><input type="button" name="yearup" class="input1" onclick="yearadd(1)" style="height:9px;width:15px"></td>
        </tr>
        <tr><td><input type="button" name="yeardown" class="input1" value="v" style="height:9px;width:15px" onclick="yearadd(-1)"></td>
        </tr>
        </table><hr size=1 width="100%" color="#c0c0c0">
        <div id=daysin></div>
    
</div>
<form action="getvalue.asp" method="post">
日期:<input name="dates" class="input1" readonly style="font-color:black"> <input type="button" class="input1" name="btndate" value="…" onclick="showdates()">
<input type="submit" value="submit" class="input1">
</form>
</body>
<script language="javascript">
function initdates()
  {
  var d=new date()
  
  days.value=d.getdate()
  months.value=d.getmonth()+1
  years.value=d.getyear()
  document.all.dates.value=d.getyear().tostring()+"-"+(d.getmonth()+1).tostring()+"-"+(d.getdate()).tostring()
  daysin.innerhtml=displaydates(d.getdate()-1,d.getmonth(),d.getyear(),true)
  }
initdates()
</script>
</html>   

———-getvalue.asp
<%=request.form("dates")
%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 送各位一个节日礼物–日期选择器(和ACTIVEX一样酷!原创)
分享到: 更多 (0)

相关推荐

  • 暂无文章