默认情况下菜单中显示的是当天日期,如果用户需要修改,可以点击下拉按钮来选择所需要的日期。
<html> <head> <meta http-equiv="content-Type" content="text/html;charset=gb2312"> <meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren"> <meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。"> <title>下拉菜单选择日期效果_武鸣人</title> </head> <body> <a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr> <!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。--> <script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script> <script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script> <SCRIPT> now = new Date(); function writeYears(obj, date) {//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) var years = date.getYear()+100 for (var i=2000; i<2050; i++) {//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) var opt = document.createElement("option") opt.text = opt.value = i obj.add(opt) } }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) function writeMonths(obj) { for (var i=1; i<13; i++) {//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) var opt = document.createElement("option") opt.text = opt.value = Math.floor(i/10) ? i : "0"+i obj.add(opt) } } function writeDate(obj, year, month) { var date = new Date(""+year+"/"+(parseInt(month)+1)+"/"+0).getDate() var selectedIndex = (date-1)<obj.selectedIndex ? (date-1) : obj.selectedIndex var len = obj.options.length if (date>len) for (var i=len+1; i<=date; i++) { var opt = document.createElement("option") opt.text = opt.value = Math.floor(i/10) ? i : "0"+i obj.add(opt) }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) else for (var i=date; i<len; i++) { obj.remove(obj.length-1) } obj.selectedIndex = selectedIndex } function changeDate() { var c_year = eval("document.forms[0].c_year") var c_month = eval("document.forms[0].c_month") var c_day = eval("document.forms[0].c_day") writeDate(c_day, c_year.options(c_year.selectedIndex).value, c_month.options(c_month.selectedIndex).value) } </SCRIPT> <FORM><SELECT onchange=changeDate() name=c_year></SELECT>年<SELECT onchange=changeDate() name=c_month></SELECT>月<SELECT name=c_day></SELECT>日</FORM> <SCRIPT language=javascript type=text/javascript> writeYears(document.forms[0].c_year, now) document.forms[0].c_year.value = now.getYear() writeMonths(document.forms[0].c_month) this_month = now.getMonth()+1 if (this_month<10){this_month = "0"+this_month} document.forms[0].c_month.value = this_month writeDate(document.forms[0].c_day, now.getYear(), now.getMonth()+1) nowday = now.getDate() if (nowday<10){nowday="0"+(now.getDate())*1} document.forms[0].c_day.value = nowday </SCRIPT> </body> </html>
本文来自武鸣人网站,转载请注明出处