标题:高手帮忙看看,为什么在firefox中onload失效
只看楼主
Nekomimi
Rank: 2
等 级:论坛游民
帖 子:80
专家分:15
注 册:2006-11-21
结帖率:100%
 问题点数:0 回复次数:1 
高手帮忙看看,为什么在firefox中onload失效
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>年月日联动</title>
<script type="text/javascript">
    //年、月赋值
    window.onload=function csh(){
        var aYear=document.getElementById("s1");
        var aMonth=document.getElementById("s2");
        var aDay=document.getElementById("s3");
        for(var i=1970;i<=2100;i++){
            var op1=new Option(i,i);
            aYear.add(op1);
        }
        for(var i=1;i<=12;i++){
            var op2=new Option(i,i);
            aMonth.add(op2);
        }
        aDay.length=0;
    }
    //判断闰年
    function ryear(y){
        if((y%4==0 && y%100!=0)||(y%400==0)){
            return 0;
        }else{
            return 1;
        }
    }
    //刷新日
    function reday(){
        var aYear=document.getElementById("s1");
        var aMonth=document.getElementById("s2");
        var aDay=document.getElementById("s3");
        aDay.length=0;                             //清空
        var op3=new Option("选择日","选择日");
        aDay.add(op3);
        var y=aYear[aYear.selectedIndex].value;
        var m=aMonth[aMonth.selectedIndex].value;
        if(m==2){
            if(ryear(y)==0){
                for(var i=1;i<30;i++){
                    op3=new Option(i,i);
                    aDay.add(op3);
                }
            }else{
                for(var i=1;i<29;i++){
                    op3=new Option(i,i);
                    aDay.add(op3);
                }
            }
        }else if(m==4||m==6||m==9||m==11){
            for(var i=1;i<31;i++){
                var op3=new Option(i,i);
                aDay.add(op3);
            }
        }else{
            for(var i=1;i<=31;i++){
                var op3=new Option(i,i);
                aDay.add(op3);
            }
        }
    }
   
    function f1(){
        var aYear=document.getElementById("s1");
        var aDay=document.getElementById("s3");
        var aMonth=document.getElementById("s2");
        var y=aYear[aYear.selectedIndex].value;
        var m=aMonth[aMonth.selectedIndex].value;
        if(m!="选择月" && y!="选择年"){
            aDay.disabled=false;
        }else{
            aDay.disabled=true;
        }
        reday();
        if(y=="选择年"){
            aDay.length=0;
        }
    }
    function f2(){
        var aYear=document.getElementById("s1");
        var aMonth=document.getElementById("s2");
        var aDay=document.getElementById("s3");
        var y=aYear[aYear.selectedIndex].value;
        var m=aMonth[aMonth.selectedIndex].value;
        if(m!="选择月" && y!="选择年"){
            aDay.disabled=false;
        }else{
            aDay.disabled=true;
        }
        reday();
        if(m=="选择月"){
            var op3=new Option("选择日","选择日");
            aDay.add(op3);
        }
    }
</script>
</head>

<body>
<select id="s1" onchange="f1()">
    <option value="选择年">选择年</option>
</select>
<select id="s2" onchange="f2()">
    <option value="选择月">选择月</option>
</select>
<select id="s3" disabled="true">
    <option value="选择日">选择日</option>
</select>
</body>
</html>
搜索更多相关主题的帖子: 失效 onload firefox 
2010-01-30 22:35
Nekomimi
Rank: 2
等 级:论坛游民
帖 子:80
专家分:15
注 册:2006-11-21
得分:0 
已经搞定了。。
2010-01-31 18:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-296922-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.177282 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved