zoukankan      html  css  js  c++  java
  • js 根据日期做星座联动,简洁

        $('#constellation').mousedown(function(){
    var constellations = new Array();
        /*  
    因本人数据库存的数据是数字,
    所以我需要返回星座来找到对应的数字,
    可根据实际情况改变
    */
          constellations['白羊座'] = "1";
    constellations['金牛座'] = "2";
    constellations['双子座'] = "3";
    constellations['巨蟹座'] = "4";
    constellations['狮子座'] = "5";
    constellations['处女座'] = "6";
    constellations['天秤座'] = "7";
    constellations['天蝎座'] = "8";
    constellations['射手座'] = "9";
    constellations['摩羯座'] = "10";
    constellations['水瓶座'] = "11";
    constellations['双鱼座'] = "12";

    var birth = $('#dateBirth').val();
    if(birth !==''){
    var m = birth.substr(5,2);
    var d = birth.substr(8,2);
    var consname = getAstro(m,d)+'座';
    $("#constellation").html('<option value="'+constellations[consname]+'">'+consname+'</option>');

    }

    })


    });
    function getAstro(m,d){

    return "魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯".substr(m*2-(d<"102123444543".charAt(m-1)- -19)*2,2);
    // return m-(d<"102223444433".charAt(m-1)- -19);
    }
  • 相关阅读:
    English trip V1
    English trip V1
    第一类斯特林数
    bzoj 3601 一个人的数论
    bzoj 4407 于神之怒加强版
    bzoj 2693 jzptab
    bzoj 4184 shallot
    luogu P3920 [WC2014]紫荆花之恋
    bzoj 4269 再见Xor
    luogu P2183 [国家集训队]礼物
  • 原文地址:https://www.cnblogs.com/xiangxu/p/5646164.html
Copyright © 2011-2022 走看看