告诉大家一个图形化输入日期的方法代码:
结果:
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title> New Document </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> </head> <body> <!-- 日期输入控件 作者:浪子 版权所有:EOB论坛 http://www.eob.cn/bbs 2005-5-28 --> <script language="javascript"> <!-- function Display(date) { var temphtml = "<style>td{font-size:9pt;text-align:center;}</style><table cellpadding=3 cellspacing=1 border=0 bgcolor=FFFFFF width=320><tr bgcolor=FFFFFF><td align=left width=50><a href=’javascript:parent.Display(new Date(" + date.getYear() + "," + (date.getMonth()-1) + "," + date.getDate() + "));’><<<<</a></td><td width=220>" + date.getYear() + "年 " + (date.getMonth() + 1) + "月 " + "</td><td align=right width=50><a href=’javascript:parent.Display(new Date(" + date.getYear() + "," + (date.getMonth()+1) + "," + date.getDate() + "));’>>>>></a></td></tr></table><table cellpadding=3 cellspacing=1 border=0 bgcolor=669933 width=320><tr bgcolor=99BB66><td>星期天</td><td>星期一</td><td>星期二</td><td>星期三</td><td>星期四</td><td>星期五</td><td>星期六</td></tr><tr>"; var curdate = new Date(); var ldate = new Date(); var j=1; curdate.setFullYear(date.getFullYear(), date.getMonth(), 1); for(var n=0;n<curdate.getDay();n++,j++) { if ((j % 7) == 0) { temphtml += "<td bgcolor=FFFFFF> </td></tr><tr>"; } else { temphtml += "<td bgcolor=FFFFFF> </td>"; } } n = 1 for(var i=1;date.getMonth() == curdate.getMonth(); i++, j++, curdate.setFullYear(date.getFullYear(), date.getMonth(), i)) { if ( parseInt(ldate.getDate(), 10) == parseInt(curdate.getDate(), 10) && parseInt(ldate.getMonth(), 10) == parseInt(curdate.getMonth(), 10) && parseInt(ldate.getYear(), 10) == parseInt(curdate.getYear(), 10) ) { if ((j % 7) == 0) { temphtml += "<td bgcolor=FFFFFF onmouseover=’this.style.background=\"99BB66\"’ onmouseout=’this.style.background=\"FFFFFF\"’ style=’cursor:hand;’ onclick=’parent.SetValue(\"" + curdate.getYear() + "-" + (curdate.getMonth()+1) + "-" + curdate.getDate() + "\");’><font color=red>" + curdate.getDate() + "</font></td></tr><tr>"; } else { temphtml += "<td bgcolor=FFFFFF onmouseover=’this.style.background=\"99BB66\"’ onmouseout=’this.style.background=\"FFFFFF\"’ style=’cursor:hand;’ onclick=’parent.SetValue(\"" + curdate.getYear() + "-" + (curdate.getMonth()+1) + "-" + curdate.getDate() + "\");’><font color=red>" + curdate.getDate() + "</font></td>"; } } else { if ((j % 7) == 0) { temphtml += "<td bgcolor=FFFFFF onmouseover=’this.style.background=\"99BB66\"’ onmouseout=’this.style.background=\"FFFFFF\"’ style=’cursor:hand;’ onclick=’parent.SetValue(\"" + curdate.getYear() + "-" + (curdate.getMonth()+1) + "-" + curdate.getDate() + "\");’>" + curdate.getDate() + "</td></tr><tr>"; } else { temphtml += "<td bgcolor=FFFFFF onmouseover=’this.style.background=\"99BB66\"’ onmouseout=’this.style.background=\"FFFFFF\"’ style=’cursor:hand;’ onclick=’parent.SetValue(\"" + curdate.getYear() + "-" + (curdate.getMonth()+1) + "-" + curdate.getDate() + "\");’>" + curdate.getDate() + "</td>"; } } |
}
j--;
if ((j % 7) == 0)
{
temphtml = temphtml.substr(0,temphtml.length-4);
temphtml += "</table>";
}
else
{
while( (j % 7) != 0)
{
temphtml += "<td bgcolor=FFFFFF> </td>"
j++;
}
temphtml += "</tr></table>";
}
datectrl.document.open();
datectrl.document.write(temphtml);
datectrl.document.close();
//parent.document.getElementById("datectrl").style.display = "";
//top.document.getElementById("datectrl").style.left = event.x + 20;
//top.document.getElementById("datectrl").style.top = event.y + 20;
//alert(temphtml);
}
function SetValue(value)
{
//obj.value = value;
//alert(value);
dd.value = value;
document.getElementById("datectrl").style.display = "none";
}
-->
</script>
<input type="text" id="dd" name="dd" value="" readonly="yes"><input type="button" value="选择日期" onclick=’if (dd.value ==""){Display(new Date());document.getElementById("datectrl").style.display = "";} else {var t =dd.value.split("-");Display(new Date(t[0],t[1]-1,t[2]));document.getElementById("datectrl").style.display = "";}’>
<iframe frameborder="0" hspace="0" marginheight="0" marginwidth="0" name="datectrl" id="datectrl" scrolling="no" vspace="0"
width="320" height="182" src="" style="display:none;z-index:1000;position:absolute;"></iframe>
</body>
</html>
相关视频
相关阅读 Windows错误代码大全 Windows错误代码查询excel数字变成代码怎么办zepeto怎么看代码lol源代码乐芙兰怎么领取 lol源代码乐芙兰领取条件奇迹暖暖危险代码虚拟之镰怎么搭配 危险代码虚拟之镰高分搭配推荐myeclipse怎么显示代码行数 myeclipse显示代码行数设置方法噬血代码特典奖励及PS4各版本区别一览 噬血代码预购奖励是什么噬血代码多人模式介绍 噬血代码多人模式怎么玩
热门文章 没有查询到任何记录。
最新文章
迅雷新手完全入门手册
asp下面javascript上传图片限制格式大小方法告诉大家网页弹出窗口应用总结ASP常见错误类型大全asp常见错误分析和解决办法
人气排行 总是弹出visual studio 实时调试器 三种解决SQLSERVER存储过程及调用详解Asp获取真实IP地址ASP中连接Mssql的几种方法一个简单好用的UBB编辑器(含代码)如何用Split将字符串转换为数组并获取数组下ASP防止表单重复提交的办法告诉你免费的简单聊天室源代码
查看所有0条评论>>