1个回答
展开全部
<html>
<head>
<script type="text/javascript">
function f(value){
var sel=document.getElementById("sel");
sel.innerHTML='';
var cyear;
if(value==null){
var now=new Date();
cyear=now.getYear();
}else{
cyear=value;
}
for(var i=0;i<=20;i++){
var op=new Option();
op.value=parseInt(cyear)-(10-i);
op.text=parseInt(cyear)-(10-i);
sel.options.add(op);
}
sel.selectedIndex=10;
}
window.onload=f;
</script>
</head>
<body>
<select id="sel" onchange="f(this.value)"></select>
</body>
</html>
<head>
<script type="text/javascript">
function f(value){
var sel=document.getElementById("sel");
sel.innerHTML='';
var cyear;
if(value==null){
var now=new Date();
cyear=now.getYear();
}else{
cyear=value;
}
for(var i=0;i<=20;i++){
var op=new Option();
op.value=parseInt(cyear)-(10-i);
op.text=parseInt(cyear)-(10-i);
sel.options.add(op);
}
sel.selectedIndex=10;
}
window.onload=f;
</script>
</head>
<body>
<select id="sel" onchange="f(this.value)"></select>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询