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);
    }
  • 相关阅读:
    可视化XHTML编辑器
    诺基亚E63内存清理法
    C语言第0次作业
    C语言博客作业03函数
    C博客作业01分支、顺序结构
    C语言博客作业02循环结构
    心情随笔
    沉没成本
    检索了MEG 和EEG,以及棘波的论文
    解决投稿问题
  • 原文地址:https://www.cnblogs.com/xiangxu/p/5646164.html
Copyright © 2011-2022 走看看