自由天天网
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Javascript 时间日期输入插件

向下

Javascript 时间日期输入插件 Empty Javascript 时间日期输入插件

帖子 由 Admin 周五 三月 20, 2009 8:06 pm

riqi.htm的代码如下:


选择时间

.input1 {
BORDER-RIGHT: black 0px solid; BORDER-TOP: black 0px solid; FONT-SIZE: 9pt; BACKGROUND: none transparent scroll repeat 0% 0%; BORDER-LEFT: black 0px solid; CURSOR: hand; BORDER-BOTTOM: black 0px solid; FONT-FAMILY: "宋体"; HEIGHT: 15px
}
TD {
FONT-SIZE: 9pt; FONT-FAMILY: "宋体"
}
SELECT {
FONT-SIZE: 9pt; FONT-FAMILY: "宋体"
}
INPUT {
FONT-SIZE: 9pt; LINE-HEIGHT: 12pt; FONT-FAMILY: "宋体"; HEIGHT: 18px
}



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="" for (var i=0;i0){ ++currentdate tmps=tmps+writedate(currentdate) } else if(i*7+j>=startday){ ++currentdate tmps=tmps+writedate(currentdate) }else tmps=tmps+" " tmps=tmps+"" } tmps=tmps+"" } tmps=tmps+"
"
return tmps
}

function writedate(n){
return ""
}

function setvalue(n)
{
window.returnValue=document.all.years.value+"-"+document.all.months.value+"-"+n
document.all.days.value=n.toString()
window.close();
}

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))
}






Javascript 时间日期输入插件 Up
一月 二月 三月 四月 五月 六月 七月 八月 九月 十月 十一月 十二月
Javascript 时间日期输入插件 Down



//显示时间
function initdates()
{
var d=new Date()

days.value=d.getDate()
months.value=d.getMonth()+1
years.value=d.getYear()
window.returnValue = ""
http://window.returnValue=d.getYear().toString()+"-"+(d.getMonth()+1).toString()+"-"+(d.getDate()).toString()
daysin.innerHTML=displaydates(d.getDate()-1,d.getMonth(),d.getYear(),true)
}
initdates();



调用它的函数如下:

function selecttime(n){
var timestring = showModalDialog("riqi.htm", "", "dialogLeft:"+(event.screenX-80)+";dialogTop:"+(event.screenY-80)+";dialogWidth:165px; dialogHeight:180px; edge:raised;help:off;status:off;scroll:off");
if(timestring!=""){
document.getElementById(n).value= timestring;
}
}


onClick="selecttime('text'); text-->文本框的名字!
还有两个小图片,加进去
http://hiphotos.baidu.com/rczjp/pic/item/a6f2e61fbf84e562f724e427.jpg
http://hiphotos.baidu.com/rczjp/pic/item/5eabaa0969ee78256a60fb27.jpg
Admin
Admin
Admin

帖子数 : 154
注册日期 : 08-12-04

http://3www.365luntan.com

返回页首 向下

Javascript 时间日期输入插件 Empty 回复: Javascript 时间日期输入插件

帖子 由 Admin 周五 三月 20, 2009 8:11 pm

Admin
Admin
Admin

帖子数 : 154
注册日期 : 08-12-04

http://3www.365luntan.com

返回页首 向下

返回页首


 
您在这个论坛的权限:
不能在这个论坛回复主题