最近用到了一个选择日期的代码,和大家分享一下:
var DS_x,DS_y;
function dateSelector()
//构造dateSelector对象,用来实现一个日历形式的日期输入框。
{
var myDate=new Date();
this.year=myDate.getFullYear(); //定义year属性,年份,默认值为当前系统年份。
this.month=myDate.getMonth()+1; //定义month属性,月份,默认值为当前系统月份。
this.date=myDate.getDate(); //定义date属性,日,默认值为当前系统的日。
this.inputName='';
//定义inputName属性,即输入框的name,默认值为空。注意:在同一页中出现多个日期输入框,不能有重复的name!
this.display=display; //定义display方法,用来显示日期输入框。
}
function display()
//定义dateSelector的display方法,它将实现一个日历形式的日期选择框。
{
var week=new Array('日','一','二','三','四','五','六');
document.write("
document.write(" .ds_font td,span { font: normal 12px 宋体; color:
#000000; }");
document.write(" .ds_border { border: 1px solid #000000; cursor:
hand; background-color: #DDDDDD }");
document.write(" .ds_border2 { border: 1px solid #000000; cursor:
hand; background-color: #DDDDDD }");
document.write("");
document.write("
size='10' id='DS_"+this.inputName+"' name='"+this.inputName+"'
value='"+this.year+"-"+this.month+"-"+this.date+"' title=双击可进行编缉
οndblclick='this.readOnly=false;this.focus()'
οnblur='this.readOnly=true'
οnfοcus=this.nextSibling.style.display='block'
readonly>");
//document.write("
style='width:30px;height:18px;font-size:12px;margin:1px;border:1px
solid #A4B3C8;background-color:#DFE7EF;' type=button
οnclick=this.nextSibling.style.display='block'
οnfοcus=this.blur()>+
");document.write("
style=