一般是年份有一个下拉列表,表格中有100个值.在月份中有12个值,日期当中有31个值.或者是要求用户输入的是1900/01/01这种格式.请教!!!!!!有没有人知道在网页设计中的用户注册中,出生年月日是怎么做的?一般是有三个下拉列表,年份表格中有100个值.在月份中有12个值,日期当中有31个值.而日期中的值随着年份和月份的改变而发生相应的改变..或者是要求用户输入的是1900/01/01这种格式
用这个js:<script language="JavaScript">var gdCtrl = new Object();var SynCtl = new Object();var goSelectTag = new Array();var overcolor="#FF6600";var gcGray = "#999999";var gcToggle = "#FFFF99";var gcBG = "#FFFFF4";var titleBG="#3399CC";var previousObject = null;var oPopup = window.createPopup();var gdCurDate = new Date();var giYear = gdCurDate.getFullYear();var giMonth = gdCurDate.getMonth()+1;var giDay = gdCurDate.getDate();function shutup(){ oPopup.hide();}function fSetDate(iYear, iMonth, iDay){ VicPopCal.style.visibility = "hidden"; if ((iYear == 0) && (iMonth == 0) && (iDay == 0)){ gdCtrl.value = ""; }else{ iMonth = iMonth + 100 + ""; iMonth = iMonth.substring(1); iDay = iDay + 100 + ""; iDay = iDay.substring(1); if(gdCtrl.tagName == "INPUT"){ gdCtrl.value = iYear+"-"+iMonth+"-"+iDay; if(SynCtl!=null) SynCtl.value = iYear+"-"+iMonth+"-"+iDay; }else{ gdCtrl.innerText = iYear+"-"+iMonth+"-"+iDay; if(SynCtl!=null) SynCtl.innerText = iYear+"-"+iMonth+"-"+iDay; } }}function fSetSelected(aCell){ var iOffset = 0; var iYear = parseInt(tbSelYear.value); var iMonth = parseInt(tbSelMonth.value);aCell.bgColor = gcBG; with (aCell.children["cellText"]){ var iDay = parseInt(innerText); if (color==gcGray) iOffset = (Victor<10)?-1:1; iMonth += iOffset; if (iMonth<1) { iYear--; iMonth = 12; }else if (iMonth>12){ iYear++; iMonth = 1; } } fSetDate(iYear, iMonth, iDay); shutup();}function Point(iX, iY){ this.x = iX; this.y = iY;}function fBuildCal(iYear, iMonth) { var aMonth=new Array(); for(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 (d = 0; d < 7; d++) aMonth[1][d] = (d<iDayOfFirst)?-(iOffsetLast+d):iDate++; for (w = 2; w < 7; w++) for (d = 0; d < 7; d++) aMonth[w][d] = (iDate<=iDaysInMonth)?iDate++:-(iNext++); return aMonth;}function fDrawCal(iYear, iMonth, iCellHeight, sDateTextSize) { var WeekDay = new Array("日","一","二","三","四","五","六"); var styleTD = " bgcolor='"+titleBG+"' valign='middle' align='center' height='"+iCellHeight+"' style='font:bold "+sDateTextSize+";"; //Coded by Liming Weng(Victor Won) email:victorwon@sina.com var styleTDBG = " bgcolor='"+gcBG+"' valign='middle' align='center' height='"+iCellHeight+"' style='font:"+sDateTextSize+";"; with (document) { write("<tr>"); for(i=0; i<7; i++){ write("<td "+styleTD+"color:#ffffff' >"+ WeekDay[i] + "</td>"); } write("</tr>");for (w = 1; w < 7; w++) { write("<tr>"); for (d = 0; d < 7; d++) { write("<td id=calCell "+styleTDBG+"cursor:hand;' onMouseOver='this.bgColor=parent.gcToggle' onMouseOut='this.bgColor=parent.gcBG' onclick='parent.fSetSelected(this)'>"); write("<font id=cellText Victor='Liming Weng'> </font>"); write("</td>") } write("</tr>"); } }}function fUpdateCal(iYear, iMonth) { tbSelMonth.options[iMonth-1].selected = true; for (i = 0; i < tbSelYear.length; i++) if (tbSelYear.options[i].value == iYear){ tbSelYear.options[i].selected = true; } myMonth = fBuildCal(iYear, iMonth); var i = 0; for (w = 0; w < 6; w++) for (d = 0; d < 7; d++) with (cellText[(7*w)+d]) { Victor = i++; if (myMonth[w+1][d]<0) { color = gcGray; innerText = -myMonth[w+1][d]; }else{ color = ((d==0)||(d==6))?"#FF3300":"#009900"; innerText = myMonth[w+1][d]; } } updatePopup(VicPopCal.innerHTML);}function fSetYearMon(iYear, iMon){ tbSelMonth.options[iMon-1].selected = true; for (i = 0; i < tbSelYear.length; i++) if (tbSelYear.options[i].value == iYear){ tbSelYear.options[i].selected = true; } fUpdateCal(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!="BODY"); return pt;}// Main: popCtrl is the widget beyond which you want this calendar to appear;// dateCtrl is the widget into which you want to put the selected date.// i.e.: <input type="text" name="dc" style="text-align:center" readonly><INPUT type="button" value="V" onclick="fPopCalendar(dc,dc);return false">function fPopCalendar(popCtrl, dateCtrl,strDate){ previousObject = popCtrl; gdCtrl = dateCtrl; SynCtl = strDate; fInitialDate(strDate); fSetYearMon(giYear, giMonth); var point = fGetXY(popCtrl); with (VicPopCal.style) { left = point.x; top = point.y+popCtrl.offsetHeight; //width = VicPopCal.offsetWidth; width = 206; // Added by Danian Zhang/SUI height = VicPopCal.offsetHeight;// visibility = 'visible'; } updatePopup(VicPopCal.innerHTML); var popLeft=parseInt(VicPopCal.style.left); var popTop=parseInt(VicPopCal.style.top); var popWidth=parseInt(VicPopCal.style.width); var popHeight=parseInt(VicPopCal.style.height); oPopup.show(popLeft,popTop,popWidth,popHeight,document.body);}function fPopSimulateCalendar(popCtrlID, dateCtrlID,strDate){ var itemID; var popCtrl,dateCtrl; with (document.all.tags("INPUT")){ for (i=0;i<length;i++){ if(item(i).type=="text"){ itemID=item(i).id; if(itemID.indexOf(popCtrlID)>-1){ popCtrl=item(i); dateCtrl=item(i); break; } } } } previousObject = popCtrl; gdCtrl = dateCtrl; SynCtl = strDate; fInitialDate(strDate); fSetYearMon(giYear, giMonth); var point = fGetXY(popCtrl); with (VicPopCal.style) { left = point.x; top = point.y+popCtrl.offsetHeight; //width = VicPopCal.offsetWidth; width = 206; // Added by Danian Zhang/SUI height = VicPopCal.offsetHeight;// visibility = 'visible'; } updatePopup(VicPopCal.innerHTML); var popLeft=parseInt(VicPopCal.style.left); var popTop=parseInt(VicPopCal.style.top); var popWidth=parseInt(VicPopCal.style.width); var popHeight=parseInt(VicPopCal.style.height); oPopup.show(popLeft,popTop,popWidth,popHeight,document.body);}function updatePopup(innerString){ var oPopupBody = oPopup.document.body; oPopupBody.innerHTML =innerString;}// Added by Danian Zhang/SUIfunction fInitialDate(strDate){ if( strDate == null || strDate.length != 10 ) return false;var sYear = strDate.substring(0,4); var sMonth = strDate.substring(5,7); var sDay = strDate.substring(8,10);if( sMonth.charAt(0) == '0' ) { sMonth = sMonth.substring(1,2); } if( sDay.charAt(0) == '0' ) { sDay = sDay.substring(1,2); }var nYear = parseInt(sYear ); var nMonth = parseInt(sMonth); var nDay = parseInt(sDay );if ( isNaN(nYear ) ) return false; if ( isNaN(nMonth) ) return false; if ( isNaN(nDay ) ) return false;var arrMon = new Array(12); arrMon[ 0] = 31; arrMon[ 1] = nYear % 4 == 0 ? 29:28; arrMon[ 2] = 31; arrMon[ 3] = 30; arrMon[ 4] = 31; arrMon[ 5] = 30; arrMon[ 6] = 31; arrMon[ 7] = 31; arrMon[ 8] = 30; arrMon[ 9] = 31; arrMon[10] = 30; arrMon[11] = 31;if ( nYear < 1900 || nYear > 2100 ) return false; if ( nMonth < 1 || nMonth > 12 ) return false; if ( nDay < 1 || nDay > arrMon[nMonth - 1] ) return false;giYear = nYear; giMonth = nMonth; giDay = nDay; return true;}var gMonths = new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");with (document) {write("<Div id='VicPopCal' onblur='parent.shutup()' style='OVERFLOW:hidden;POSITION:absolute;VISIBILITY:hidden;width:180;z-index:100;'>");write("<table width='100%' border='1' cellpadding='0' cellspacing='0' style='background-color:#EFF7FF;border-width:1px ;border-color:#3399CC;'>");write("<TR><TD>")write("<table width='100%' border='0' cellpadding='0' cellspacing='0' >");write("<TR>");write("<td valign='middle' align='center' style='font-size:9pt;background-color:#EFF7FF' HEIGHT='28'>");write("<SELECT name='tbSelYear' onChange='parent.fUpdateCal(tbSelYear.value, tbSelMonth.value)' style='width:80' Victor='Won'>");for(i=1900;i<2050;i++) write("<OPTION value='"+i+"'>"+i+" 年</OPTION>");write("</SELECT>");write(" <select name='tbSelMonth' onChange='parent.fUpdateCal(tbSelYear.value, tbSelMonth.value)' style='width:80' Victor='Won'>");for (i=0; i<12; i++) write("<option value='"+(i+1)+"'>"+gMonths[i]+"</option>");write("</SELECT>");write("</td>");write("</TR><TR>");write("<td align='center'>");write("<table width='95%' border='1' cellspacing='0' cellpadding='0' bordercolordark='#639ace' bodercolorlight='#ffffff'>");fDrawCal(giYear, giMonth, 20, '9pt');write("</table>");write("</td>");write("</TR><TR><TD align='center'>");write("<TABLE width='98%'><TR><TD nowrap align='center' HEIGHT='25'>");write("<span style='cursor:hand;font-size:9pt' onclick='parent.fSetDate(0,0,0)' onMouseOver='this.style.color=parent.overcolor' onMouseOut='this.style.color=0'>清空</span>");write("</td><td algin='center' HEIGHT='25'>");write("<span style='cursor:hand;font-size:9pt' onclick='parent.fSetDate("+giYear+","+giMonth+","+giDay+")' onMouseOver='this.style.color=parent.overcolor' onMouseOut='this.style.color=0'> 今天: "+giYear+"-"+giMonth+"-"+giDay+"</span></td>");write("<td nowrap HEIGHT='25'><span style='cursor:hand;font-size:9pt' onMouseOver='this.style.color=parent.overcolor' onMouseOut='this.style.color=0' onclick='parent.shutup()'>关闭</span></td></tr></table>");write("</TD></TR>");write("</TABLE></TD></TR></TABLE></Div>");}</script>添加一个按钮:<button onclick="fPopCalendar(invalidateDate,invalidateDate);return false" name="button" type="button">q</button> invalidateDate为变量可任意命名 我这js都写的这么明白了!你还不知道怎么弄啊?