百分求一个日历的javascript代码
劳烦提供一个日历的javascript代码
效果是点击DIV中的一个TEXT,出现一个日历,可以选择日期,选择完后TEXT中就显示选中的日期
------解决方案--------------------function selecttimefun(){
var timestring = showModalDialog( "/huadu_master_admins/seledatetime.jsp ", " ", "dialogLeft: "+(event.screenX-80)+ ";dialogTop: "+(event.screenY-80)+ ";dialogWidth:165px; dialogHeight:165px; edge:raised;help:off;status:off;scroll:off ");
if(timestring!= " ")
{
document.form3.times_exps.value = timestring;
document.getElementById( "times ").innerHTML=timestring;
}
}
-------------------------------------------------
<%@ page language= "java " contentType= "text/html; charset=utf-8 "
pageEncoding= "utf-8 "%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<title> 选择时间 </title>
<style>
.input1{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;}
input{font-family: "宋体 "; font-size:9pt;height:18px;line-height: 12pt;}
</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> </tr> <tr> <td colspan=7 bgcolor=black> <spacer height=1 type=block> </td> </tr> "
for (var i=0;i <numrows;++i)
{
tmps=tmps+ " <tr> "
for(var j=0;j <7;++j){
if (shade&&day==currentdate&¤tdate <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