<div class="htmlarea"> <textarea id="runcode44952"> <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> <select size="1" id="yearSelect" name="yearSelect" onchange="selYear('yearSelect',this.value)"></select> <script>selYear('yearSelect',2005) //初试化select</script> </textarea><br><input onclick="runEx('runcode44952')" type="button" value="运行代码"> <input onclick="doCopy('runcode44952')" type="button" value="复制代码"> <input onclick="doSave(runcode44952)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div>