日期输入控件么??正好我在搞````// JScript 文件
<!--
function Calendar(name){ //创建主对象
document.write('<div id="calendar" style="width:175px;background-color:Gray;display:none;"></div>');
this.name = name;
this.now = new Date();
this.year = 1990;
this.month = 0;
this.day = 1;
this.monthName = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
this.weekName = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
this.daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,30, 31, 30, 31);
this.element = document.getElementById('calendar');
this.init();
}Calendar.prototype.setext=function(day){
document.getElementById("text1").value=this.year+"-"+(this.month+1)+"-"+day;
alert(this.year+"-"+(this.month+1)+"-"+day);
document.getElementById('calendar').style.display="none";
}Calendar.prototype.init = function() {
var strHtml = '';
strHtml += this.createHead();
strHtml += this.createWeek();
strHtml += this.createDays();
strHtml += this.createFoot();
this.element.innerHTML = strHtml;
}
Calendar.prototype.getDays = function() {
if (1 == this.month) return ((0 == this.year % 4) && (0 != (this.year % 100))) ||(0 == this.year % 400) ? 29 : 28;
else return this.daysInMonth[this.month];
}
Calendar.prototype.createHead = function() {
return '<span class="head">' + this.monthName[this.month] + ' ' + this.year + '</span>';
}
Calendar.prototype.createWeek = function() {
var strResult = '';
for (var i = 0; i < 7; i++) {
if (i == 0 || i == 6) strResult += '<span class="we">';
else strResult += '<span class="ww">';
strResult += this.weekName[i].substr(0,2) + '</span>';
}
return strResult;
}
Calendar.prototype.createDays = function() {
var strResult = '';
var i = 0;
var d = this.getDays();
var n = Math.ceil(d / 7) * 7;
var w = new Date(this.year, this.month, 1).getDay();
for (var j = 0; j < w; j++) { //输出前空格
i += 1;
strResult += '<span> </span>';
}
for (var j = 1; j <= d; j++) { //输出日期格
i += 1;
if (j == this.day&&this.month==this.now.getMonth()&&this.year==this.now.getFullYear()) {
strResult += '<span class="today" style=\'cursor:hand\' onMouseOver=\"this.style.background=\'#E1E1E1\'\" onMouseOut=\"this.style.background=\'#FFFFFF\'\" onClick=\"'+this.name+'.setext(\''+j+'\')\";>' + j + '</span>';
} else {
var k = new Date(this.year, this.month, j).getDay();
if (k == 0 || k == 6) {
strResult += '<span class="weekend" style=\'cursor:hand\' onMouseOver=\"this.style.background=\'#E1E1E1\'\" onMouseOut=\"this.style.background=\'#FFFFFF\'\" onClick=\"'+this.name+'.setext(\''+j+'\')\";>' + j + '</span>';
} else {
strResult += '<span style=\'cursor:hand\' id=\'aaa'+j+'\' onMouseOver=\"this.style.background=\'#E1E1E1\'\" onMouseOut=\"this.style.background=\'#FFFFFF\'\" onClick=\"'+this.name+'.setext(\''+j+'\')\";)>' + j + '</span>';
}
}
}
for (var j = 0; j < (Math.ceil(i / 7) * 7 - i); j++) { //输出后空格
strResult += '<span> </span>';
}
return strResult;
}
Calendar.prototype.createFoot = function() {
return '<span class="foot"><a href="javascript:' + this.name + '.changeMonth(\'p\');" class="arrow">3</a>MONTH<a href="javascript:' + this.name + '.changeMonth(\'n\');" class="arrow">4</a> (<a href="javascript:' + this.name + '.changeMonth(\'t\');">Today</a>) <a href="javascript:' + this.name + '.changeYear(\'p\');" class="arrow">3</a>YEAR<a href="javascript:' + this.name + '.changeYear(\'n\');" class="arrow">4</a></span>';
}
Calendar.prototype.changeYear = function(arg) {
if (arg == 'p') this.year -= 1;
if (arg == 'n') this.year += 1;
this.init();
}
Calendar.prototype.changeMonth = function(arg) {
var m;
if (arg == 'p') m = this.month - 1;
if (arg == 'n') m = this.month + 1;
if (arg == 'p' || arg == 'n') {
if ( m > -1 && m < 12) {
this.month = m;
} else if (m < 0) {
this.year -= 1;
this.month = 11;
} else if (m > 11) {
this.year += 1;
this.month = 0;
}
}
if(arg=='t')
{
this.year = this.now.getFullYear();
this.month = this.now.getMonth();
this.day = this.now.getDate();
}
this.init();
}-->
<!--
function Calendar(name){ //创建主对象
document.write('<div id="calendar" style="width:175px;background-color:Gray;display:none;"></div>');
this.name = name;
this.now = new Date();
this.year = 1990;
this.month = 0;
this.day = 1;
this.monthName = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
this.weekName = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
this.daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,30, 31, 30, 31);
this.element = document.getElementById('calendar');
this.init();
}Calendar.prototype.setext=function(day){
document.getElementById("text1").value=this.year+"-"+(this.month+1)+"-"+day;
alert(this.year+"-"+(this.month+1)+"-"+day);
document.getElementById('calendar').style.display="none";
}Calendar.prototype.init = function() {
var strHtml = '';
strHtml += this.createHead();
strHtml += this.createWeek();
strHtml += this.createDays();
strHtml += this.createFoot();
this.element.innerHTML = strHtml;
}
Calendar.prototype.getDays = function() {
if (1 == this.month) return ((0 == this.year % 4) && (0 != (this.year % 100))) ||(0 == this.year % 400) ? 29 : 28;
else return this.daysInMonth[this.month];
}
Calendar.prototype.createHead = function() {
return '<span class="head">' + this.monthName[this.month] + ' ' + this.year + '</span>';
}
Calendar.prototype.createWeek = function() {
var strResult = '';
for (var i = 0; i < 7; i++) {
if (i == 0 || i == 6) strResult += '<span class="we">';
else strResult += '<span class="ww">';
strResult += this.weekName[i].substr(0,2) + '</span>';
}
return strResult;
}
Calendar.prototype.createDays = function() {
var strResult = '';
var i = 0;
var d = this.getDays();
var n = Math.ceil(d / 7) * 7;
var w = new Date(this.year, this.month, 1).getDay();
for (var j = 0; j < w; j++) { //输出前空格
i += 1;
strResult += '<span> </span>';
}
for (var j = 1; j <= d; j++) { //输出日期格
i += 1;
if (j == this.day&&this.month==this.now.getMonth()&&this.year==this.now.getFullYear()) {
strResult += '<span class="today" style=\'cursor:hand\' onMouseOver=\"this.style.background=\'#E1E1E1\'\" onMouseOut=\"this.style.background=\'#FFFFFF\'\" onClick=\"'+this.name+'.setext(\''+j+'\')\";>' + j + '</span>';
} else {
var k = new Date(this.year, this.month, j).getDay();
if (k == 0 || k == 6) {
strResult += '<span class="weekend" style=\'cursor:hand\' onMouseOver=\"this.style.background=\'#E1E1E1\'\" onMouseOut=\"this.style.background=\'#FFFFFF\'\" onClick=\"'+this.name+'.setext(\''+j+'\')\";>' + j + '</span>';
} else {
strResult += '<span style=\'cursor:hand\' id=\'aaa'+j+'\' onMouseOver=\"this.style.background=\'#E1E1E1\'\" onMouseOut=\"this.style.background=\'#FFFFFF\'\" onClick=\"'+this.name+'.setext(\''+j+'\')\";)>' + j + '</span>';
}
}
}
for (var j = 0; j < (Math.ceil(i / 7) * 7 - i); j++) { //输出后空格
strResult += '<span> </span>';
}
return strResult;
}
Calendar.prototype.createFoot = function() {
return '<span class="foot"><a href="javascript:' + this.name + '.changeMonth(\'p\');" class="arrow">3</a>MONTH<a href="javascript:' + this.name + '.changeMonth(\'n\');" class="arrow">4</a> (<a href="javascript:' + this.name + '.changeMonth(\'t\');">Today</a>) <a href="javascript:' + this.name + '.changeYear(\'p\');" class="arrow">3</a>YEAR<a href="javascript:' + this.name + '.changeYear(\'n\');" class="arrow">4</a></span>';
}
Calendar.prototype.changeYear = function(arg) {
if (arg == 'p') this.year -= 1;
if (arg == 'n') this.year += 1;
this.init();
}
Calendar.prototype.changeMonth = function(arg) {
var m;
if (arg == 'p') m = this.month - 1;
if (arg == 'n') m = this.month + 1;
if (arg == 'p' || arg == 'n') {
if ( m > -1 && m < 12) {
this.month = m;
} else if (m < 0) {
this.year -= 1;
this.month = 11;
} else if (m > 11) {
this.year += 1;
this.month = 0;
}
}
if(arg=='t')
{
this.year = this.now.getFullYear();
this.month = this.now.getMonth();
this.day = this.now.getDate();
}
this.init();
}-->
拿这个改一下,无刷新的http://www.51aspx.com/S/dropdownlist.aspx
接收 再给select添加options
select.options(new option('显示',值));
另外一个通过这个值再去再给另外一个select添加options
三级联动无刷新,xmlhttp实现
好不容易下载下来不是我想要的我还是想拿下拉框的
hertcloud(·£孙子兵法£·) ( ) http://blog.csdn.net/hertcloud/archive/2007/04/12/1561713.aspx
这个真的很棒
我路过的
多谢
* 直接拷过去吧!
*
* 使用方法
* 控件调用onclick="fPopCalendar(event,this,this)"
* 如下,给控件设置为readonly
* <input type="text" style="border:1px solid #cccccc;"
* size="15" onclick="fPopCalendar(event,this,this)"
* onfocus="this.select()" readonly="readonly" />
*
* 如果页面乱码,把下面包含汉字的定义项放到页面中即可
********************************************************/
var gMonths=new Array("1","2","3","4","5","6","7","8","9","10","11","12");
var WeekDay=new Array("S","M","T","W","T","F","S");
var strYear="";//"年";
var strMonth="月";
var strDay="日";
var splitChar="-";
var startYear=2000;
var endYear=2050;
var dayTdHeight=12;
var dayTdTextSize=12;
var gcNotCurMonth="#E0E0E0";
var gcRestDay="#FF0000";
var gcWorkDay="#444444";
var gcMouseOver="#79D0FF";
var gcMouseOut="#F4F4F4";
var gcToday="#444444";
var gcTodayMouseOver="#6699FF";
var gcTodayMouseOut="#79D0FF";
var gdCtrl=new Object();
var goSelectTag=new Array();
var gdCurDate=new Date();
var giYear=gdCurDate.getFullYear();
var giMonth=gdCurDate.getMonth()+1;
var giDay=gdCurDate.getDate();
function $(){var elements=new Array();for(var i=0;i<arguments.length;i++) {var element=arguments[i];if(typeof(arguments[i])=='string'){element=document.getElementById(arguments[i]);}if(arguments.length==1){return element;}elements.Push(element);}return elements;}
Array.prototype.Push=function(){var startLength=this.length;for(var i=0;i<arguments.length;i++){this[startLength+i]=arguments[i];}return this.length;}
String.prototype.HexToDec=function(){return parseInt(this,16);}
String.prototype.cleanBlank=function(){return this.isEmpty()?"":this.replace(/\s/g,"");}
function checkColor(){var color_tmp=(arguments[0]+"").replace(/\s/g,"").toUpperCase();var model_tmp1=arguments[1].toUpperCase();var model_tmp2="rgb("+arguments[1].substring(1,3).HexToDec()+","+arguments[1].substring(1,3).HexToDec()+","+arguments[1].substring(5).HexToDec()+")";model_tmp2=model_tmp2.toUpperCase();if(color_tmp==model_tmp1 ||color_tmp==model_tmp2){return true;}return false;}
function $V(){return $(arguments[0]).value;}
function fPopCalendar(evt,popCtrl,dateCtrl){evt.cancelBubble=true;gdCtrl=dateCtrl;fSetYearMon(giYear,giMonth);var point=fGetXY(popCtrl);with($("calendardiv").style){left=point.x+"px";top=(point.y+popCtrl.offsetHeight+1)+"px";visibility='visible';zindex='99';position='absolute';}$("calendardiv").focus();}
function fSetDate(iYear,iMonth,iDay){var iMonthNew=new String(iMonth);var iDayNew=new String(iDay);if(iMonthNew.length<2){iMonthNew="0"+iMonthNew;}if(iDayNew.length<2){iDayNew="0"+iDayNew;}gdCtrl.value=iYear+splitChar+iMonthNew+splitChar+iDayNew;fHideCalendar();}
function fHideCalendar(){$("calendardiv").style.visibility="hidden";for(var i=0;i<goSelectTag.length;i++){goSelectTag[i].style.visibility="visible";}goSelectTag.length=0;}
function fSetSelected(){var iOffset=0;var iYear=parseInt($("tbSelYear").value);var iMonth=parseInt($("tbSelMonth").value);var aCell=$("cellText"+arguments[0]);aCell.bgColor=gcMouseOut;with(aCell){var iDay=parseInt(innerHTML);if(checkColor(style.color,gcNotCurMonth)){iOffset=(innerHTML>10)?-1:1;}iMonth+=iOffset;if(iMonth<1){iYear--;iMonth=12;}else if(iMonth>12){iYear++;iMonth=1;}}fSetDate(iYear,iMonth,iDay);}
function Point(iX,iY){this.x=iX;this.y=iY;}
function fBuildCal(iYear,iMonth){var aMonth=new Array();for(var i=1;i<7;i++){aMonth[i]=new Array(i);}var dCalDate=new Date(iYear,iMonth-1,1);var iDayOfFirst=dCalDate.getDay();var iDaysInMonth=new Date(iYear,iMonth,0).getDate();var iOffsetLast=new Date(iYear,iMonth-1,0).getDate()-iDayOfFirst+1;var iDate=1;var iNext=1;for(var d=0;d<7;d++){aMonth[1][d]=(d<iDayOfFirst)?(iOffsetLast+d)*(-1):iDate++;}for(var w=2;w<7;w++){for(var d=0;d<7;d++){aMonth[w][d]=(iDate<=iDaysInMonth)?iDate++:(iNext++)*(-1);}}return aMonth;}
function fDrawCal(iYear,iMonth,iCellHeight,iDateTextSize){var colorTD=" bgcolor='"+gcMouseOut+"' bordercolor='"+gcMouseOut+"'";var styleTD=" valign='middle' align='center' style='height:"+iCellHeight+"px;font-weight:bolder;font-size:"+iDateTextSize+"px;";var dateCal="";dateCal+="<tr>";for(var i=0;i<7;i++){dateCal+="<td"+colorTD+styleTD+"color:#990099'>"+WeekDay[i]+"</td>";}dateCal+="</tr>";for(var w=1;w<7;w++){dateCal+="<tr>";for(var d=0;d<7;d++){var tmpid=w+""+d;dateCal+="<td"+styleTD+"cursor:pointer;' onclick='fSetSelected("+tmpid+")'>";dateCal+="<span id='cellText"+tmpid+"'></span>";dateCal+="</td>";}dateCal+="</tr>";}return dateCal;}
function fUpdateCal(iYear,iMonth){var myMonth=fBuildCal(iYear,iMonth);var i=0;for(var w=1;w<7;w++){for(var d=0;d<7;d++){with($("cellText"+w+""+d)){parentNode.bgColor=gcMouseOut;parentNode.borderColor=gcMouseOut;parentNode.onmouseover=function(){this.bgColor=gcMouseOver;};parentNode.onmouseout=function(){this.bgColor=gcMouseOut;};if(myMonth[w][d]<0){style.color=gcNotCurMonth;innerHTML=Math.abs(myMonth[w][d]);}else{style.color=((d==0)||(d==6))?gcRestDay:gcWorkDay;innerHTML=myMonth[w][d];if(iYear==giYear && iMonth==giMonth && myMonth[w][d]==giDay){style.color=gcToday;parentNode.bgColor=gcTodayMouseOut;parentNode.onmouseover=function(){this.bgColor=gcTodayMouseOver;};parentNode.onmouseout=function(){this.bgColor=gcTodayMouseOut;};}}}}}}
function fSetYearMon(iYear,iMon){$("tbSelMonth").options[iMon-1].selected=true;for(var i=0;i<$("tbSelYear").length;i++){if($("tbSelYear").options[i].value==iYear){$("tbSelYear").options[i].selected=true;}}fUpdateCal(iYear,iMon);}
function fPrevMonth(){var iMon=$("tbSelMonth").value;var iYear=$("tbSelYear").value;if(--iMon<1){iMon=12;iYear--;}fSetYearMon(iYear,iMon);}
function fNextMonth(){var iMon=$("tbSelMonth").value;var iYear=$("tbSelYear").value;if(++iMon>12){iMon=1;iYear++;}fSetYearMon(iYear,iMon);}
function fGetXY(aTag){var oTmp=aTag;var pt=new Point(0,0);do{pt.x+=oTmp.offsetLeft;pt.y+=oTmp.offsetTop;oTmp=oTmp.offsetParent;}while(oTmp.tagName.toUpperCase()!="BODY");return pt;}
function getDateDiv(){var noSelectForIE="";var noSelectForFireFox="";if(document.all){noSelectForIE="onselectstart='return false;'";}else{noSelectForFireFox="-moz-user-select:none;";}var dateDiv="";dateDiv+="<div id='calendardiv' onclick='event.cancelBubble=true' "+noSelectForIE+" style='"+noSelectForFireFox+"position:absolute;z-index:99;visibility:hidden;border:1px solid #999999;'>";dateDiv+="<table border='0' bgcolor='#E0E0E0' cellpadding='1' cellspacing='1' >";dateDiv+="<tr>";dateDiv+="<td><input type='button' id='PrevMonth' value='<' style='height:20px;width:20px;font-weight:bolder;' onclick='fPrevMonth()'>";dateDiv+="</td><td><select id='tbSelYear' style='border:1px solid;' onchange='fUpdateCal($V(\"tbSelYear\"),$V(\"tbSelMonth\"))'>";for(var i=startYear;i<endYear;i++){dateDiv+="<option value='"+i+"'>"+i+strYear+"</option>";}dateDiv+="</select></td><td>";dateDiv+="<select id='tbSelMonth' style='border:1px solid;' onchange='fUpdateCal($V(\"tbSelYear\"),$V(\"tbSelMonth\"))'>";for(var i=0;i<12;i++){dateDiv+="<option value='"+(i+1)+"'>"+gMonths[i]+"</option>";}dateDiv+="</select></td><td>";dateDiv+="<input type='button' id='NextMonth' value='>' style='height:20px;width:20px;font-weight:bolder;' onclick='fNextMonth()'>";dateDiv+="</td>";dateDiv+="</tr><tr>";dateDiv+="<td align='center' colspan='4'>";dateDiv+="<div style='background-color:#cccccc'><table width='100%' border='0' cellpadding='3' cellspacing='1'>";dateDiv+=fDrawCal(giYear,giMonth,dayTdHeight,dayTdTextSize);dateDiv+="</table></div>";dateDiv+="</td>";dateDiv+="</tr><tr><td align='center' colspan='4' nowrap>";dateDiv+="</tr></tr>";dateDiv+="</table></div>";return dateDiv;}
with(document){onclick=fHideCalendar;write(getDateDiv());}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-ch" lang="zh-ch">
<head>
<title>日历控件</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="imagetoolbar" content="no" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="expires" content="0" />
<script src="date.js" type="text/javascript"></script>
</head>
<body>
<input type="text" style="border:1px solid #cccccc;" size="15" onclick="fPopCalendar(event,this,this)" onfocus="this.select()" readonly="readonly" />
</body>
</html>有什么不明白的,可以加QQ:591314009