HTML代码 < DIV > 输入时间段: 开始时间: < asp:textbox id ="txtStart" runat ="server" onfocus ="setday(this); " ReadOnly ="True" ></ asp:textbox > 结束时间 < asp:textbox id ="txtEnd" runat ="server" onfocus ="setday(this);" ReadOnly ="True" ></ asp:textbox > < asp:radiobutton id ="rbWeek" runat ="server" GroupName ="wm" onclick ="quickseldate('week');" Text ="本周" ></ asp:radiobutton > < asp:radiobutton id ="rbMonth" runat ="server" GroupName ="wm" Text ="本月" onclick ="quickseldate('month');" ></ asp:radiobutton ></ DIV > 如果要在选择框内填入两个时间段内的数据, 可以用JS来获取 JS代码如下 < script language = " javascript " > function fillstring(str) ... { if(str.length==1) ...{ str = "0" + str; } return(str); } function quickseldate(type) ... { var begintime,endtime; var oneminute = 60*1000; var onehour = 60*oneminute; var oneday = 24*onehour; var oneweek = 7*oneday; var todayDate = new Date(); var date = todayDate.getDate(); var month= todayDate.getMonth() +1; var year= todayDate.getYear(); var day = todayDate.getDay(); if(navigator.appName == "Netscape") ...{ year = 1900 + year; } //--> if(type=="day") ...{ begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString()); endtime = begintime; } else if(type=="week") ...{ var daytoMon = day-1; if(day==0) daytoMon = 6; todayDate.setTime(todayDate.getTime()-daytoMon*oneday); date = todayDate.getDate(); month= todayDate.getMonth() +1; year= todayDate.getYear(); day = todayDate.getDay(); begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString()); todayDate.setTime(todayDate.getTime()+6*oneday); date = todayDate.getDate(); month= todayDate.getMonth() +1; year= todayDate.getYear(); endtime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString()); } else if(type=="month") ...{ var dateto1 = date-1; todayDate.setTime(todayDate.getTime()-dateto1*oneday); date = todayDate.getDate(); month= todayDate.getMonth() +1; year= todayDate.getYear(); day = todayDate.getDay(); begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString()); todayDate.setMonth(month); todayDate.setTime(todayDate.getTime()-oneday); date = todayDate.getDate(); month= todayDate.getMonth() +1; year= todayDate.getYear(); endtime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString()); } document.getElementById("txtStart").value = begintime; document.getElementById("txtEnd").value = endtime; } </ script >