Home  >  Article  >  Web Front-end  >  Infinitely expanded year select_time date

Infinitely expanded year select_time date

WBOY
WBOYOriginal
2016-05-16 19:26:441046browse

[Ctrl A select all Note:
If you need to introduce external Js, you need to refresh to execute <script> //------------------------------------- // 无限扩展的年份select // // 作者: PuterJam //------------------------------------- var Lastyear function selYear(obj,Cyear){ var len=16 //select长度 var selObj=document.getElementById(obj) var selIndex=parseInt(len/2)-1 var newOpt var LY=Cyear-Lastyear for (i=0;i<len;i++){ if (selObj.options.length!=len){ newOpt=document.createElement("OPTION") newOpt.text=Cyear-selIndex+i newOpt.value=Cyear-selIndex+i selObj.options.add(newOpt,i) if (selIndex==i) {Lastyear=newOpt.value} } else { selObj.options[i].text=parseInt(selObj.options[i].text)+LY selObj.options[i].value=parseInt(selObj.options[i].value)+LY if (selIndex==i) {Lastyear=selObj.options[i].value} } } selObj.selectedIndex=selIndex } </script>]<script>selYear('yearSelect',2005) //初试化select</script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn