这是一款下拉菜单选择日期js特效,打开网页后直接在当前下拉框里面显示当天日期,方便实用的一个js日期特效。
<body bgcolor="#fef4d9" onLoad="SetToToday('FirstSelect');"> <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 LANGUAGE="JavaScript"> <!-- Begin //set todays date Now = new Date(); NowDay = Now.getDate(); NowMonth = Now.getMonth(); NowYear = Now.getYear(); if (NowYear < 2000) NowYear += 1900; //for Netscape //function for returning how many days there are in a month including leap years function DaysInMonth(WhichMonth, WhichYear) { var DaysInMonth = 31; if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30; if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))DaysInMonth = 28; if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))DaysInMonth = 29; return DaysInMonth; }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) //function to change the available days in a months function ChangeOptionDays(Which) { DaysObject = eval("document.Form1." + Which + "Day"); MonthObject = eval("document.Form1." + Which + "Month"); YearObject = eval("document.Form1." + Which + "Year"); Month = MonthObject[MonthObject.selectedIndex].text; Year = YearObject[YearObject.selectedIndex].text; DaysForThisSelection = DaysInMonth(Month, Year); CurrentDaysInSelection = DaysObject.length; if (CurrentDaysInSelection > DaysForThisSelection) { for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++) { DaysObject.options[DaysObject.options.length - 1] = null } } if (DaysForThisSelection > CurrentDaysInSelection) { for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++) { NewOption = new Option(DaysObject.options.length + 1); DaysObject.add(NewOption); } } if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0; }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) //function to set options to today function SetToToday(Which) { DaysObject = eval("document.Form1." + Which + "Day"); MonthObject = eval("document.Form1." + Which + "Month"); YearObject = eval("document.Form1." + Which + "Year"); YearObject[0].selected = true; MonthObject[NowMonth].selected = true; ChangeOptionDays(Which); DaysObject[NowDay-1].selected = true; } //function to write option years plus x function WriteYearOptions(YearsAhead) { line = ""; for (i=0; i<YearsAhead; i++) { line += "<OPTION>"; line += NowYear + i; } return line; }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) // End --> </script> <FORM name="Form1"> <SELECT name="FirstSelectDay"> <OPTION>1</OPTION> <OPTION>2</OPTION> <OPTION>3</OPTION> <OPTION>4</OPTION> <OPTION>5</OPTION> <OPTION>6</OPTION> <OPTION>7</OPTION> <OPTION>8</OPTION> <OPTION>9</OPTION> <OPTION>10</OPTION> <OPTION>11</OPTION> <OPTION>12</OPTION> <OPTION>13</OPTION> <OPTION>14</OPTION> <OPTION>15</OPTION> <OPTION>16</OPTION> <OPTION>17</OPTION> <OPTION>18</OPTION> <OPTION>19</OPTION> <OPTION>20</OPTION> <OPTION>21</OPTION> <OPTION>22</OPTION> <OPTION>23</OPTION> <OPTION>24</OPTION> <OPTION>25</OPTION> <OPTION>26</OPTION> <OPTION>27</OPTION> <OPTION>28</OPTION> <OPTION>29</OPTION> <OPTION>30</OPTION> <OPTION>31</OPTION> </SELECT> <SELECT name="FirstSelectMonth" onchange="ChangeOptionDays('FirstSelect')"> <OPTION>Jan</OPTION> <OPTION>Feb</OPTION> <OPTION>Mar</OPTION> <OPTION>Apr</OPTION> <OPTION>May</OPTION> <OPTION>Jun</OPTION> <OPTION>Jul</OPTION> <OPTION>Aug</OPTION> <OPTION>Sep</OPTION> <OPTION>Oct</OPTION> <OPTION>Nov</OPTION> <OPTION>Dec</OPTION> </SELECT> <SELECT name="FirstSelectYear" onchange="ChangeOptionDays('FirstSelect')"> <SCRIPT language="JavaScript"> document.write(WriteYearOptions(50)); </SCRIPT> </SELECT> </FORM> </body>
本文来自武鸣人网站,转载请注明出处