Maison > interface Web > js tutoriel > le corps du texte

js日期、星座的级联显示代码_javascript技巧

WBOY
Libérer: 2016-05-16 17:02:56
original
1024 Les gens l'ont consulté

js 代码

复制代码 代码如下:

    function birthdayOnchange(obj) {
        var year = $("").value;

        if (year == "year")
            return;
        else
            year = parseInt(year, 10);


        var month = $("").value;
        if (month == "month")
            return;
        else
            month = parseInt(month, 10);

        var day = $("").value;
        var wholeday = getDays(year, month);

        if (1) {
            var options = $("").options;
            for (var i = 1; i                 var j = i.toString();
                j = j.length == 1 ? "0" + j : j;
                options.length = i + 1;
                options[i].value = j;
                options[i].text = j;
                if (day                     options[i].selected = true;
                }
            }
        }
    }

 function getDays(year, month) {
        var dayarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

        if (month == 2) {
            if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0 || year                 return 29;
            else
                return dayarr[month - 1];
        }
        else {
            return dayarr[month - 1];
        }
    }

    function adjustAstro() {
        var v_astro = getAstro($("").value, $("").value);
        $("").options[0].text = v_astro;
    }

    function getAstro(v_month, v_day) {
        v_month = parseInt(v_month, 10)
        v_day = parseInt(v_day, 10);

        if ((v_month == 12 && v_day >= 22)
  || (v_month == 1 && v_day             return "魔羯座";
        }
        else if ((v_month == 1 && v_day >= 21)
  || (v_month == 2 && v_day             return "水瓶座";
        }
        else if ((v_month == 2 && v_day >= 20)
  || (v_month == 3 && v_day             return "双鱼座";
        }
        else if ((v_month == 3 && v_day >= 21)
  || (v_month == 4 && v_day             return "白羊座";
        }
        else if ((v_month == 4 && v_day >= 21)
  || (v_month == 5 && v_day             return "金牛座";
        }
        else if ((v_month == 5 && v_day >= 22)
  || (v_month == 6 && v_day             return "双子座";
        }
        else if ((v_month == 6 && v_day >= 22)
  || (v_month == 7 && v_day             return "巨蟹座";
        }
        else if ((v_month == 7 && v_day >= 23)
  || (v_month == 8 && v_day             return "狮子座";
        }
        else if ((v_month == 8 && v_day >= 24)
  || (v_month == 9 && v_day             return "处女座";
        }
        else if ((v_month == 9 && v_day >= 24)
  || (v_month == 10 && v_day             return "天秤座";
        }
        else if ((v_month == 10 && v_day >= 24)
  || (v_month == 11 && v_day             return "天蝎座";
        }
        else if ((v_month == 11 && v_day >= 23)
  || (v_month == 12 && v_day             return "射手座";
        }
        return "";
    }


html
复制代码 代码如下:

               
出生日期:

               

                   
                   
                   
               

               

星座:

               

                   
               

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!