Javascript 时间日期输入插件
Javascript 时间日期输入插件
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="
"
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))
}
//显示时间
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
选择时间
.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="
日 | 一 | 二 | 三 | 四 | 五 | 六 |
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))
}
| | 一月 二月 三月 四月 五月 六月 七月 八月 九月 十月 十一月 十二月 |
|
//显示时间
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
您在这个论坛的权限:
您不能在这个论坛回复主题