dabocaiqq
dabocaiqq
2018-07-20 02:54
采纳率: 66.6%
浏览 930

javascript都来回答,怎么实现下拉选择日期的功能,JQ或者JS怎么实现?

javascript都来回答,怎么实现下拉选择日期的功能,JQ或者JS怎么实现?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

9条回答 默认 最新

  • showbo
    已采纳

    一直在用my97...
    http://www.my97.net/

    点赞 评论
  • qq_16382789
    qq_16382789 2018-07-20 02:56

    WebCalendar.js可以实现

    点赞 评论
  • qq_37613868
    qq_37613868 2018-07-20 03:11

    tp3框架,原生态代码


    出生日期:


    //选择日期 function OpenTime(e){ art.dialog.open('OpenTime',{lock:true,title:'选择日期',width:320,height:150,yesText:'关闭',background: '#000',opacity: 0.45,}); }

    <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">










    TREE易芝树感官餐厅
    *{margin:0;padding:0;font-family:"微软雅黑";} ul{ width:100%; display:flex; } li{ width:30%; margin:0 auto; list-style:none; } select{ width:100%; padding:5px 10px; } .title{height:40px;} .title li{ height:40px; text-align:center; line-height:40px; font-size:18px; font-weight:bold; } .button{ width:96%; height:40px; margin-top:20px; background:#cd010d; display:inline-block; text-decoration:none; line-height:40px; color:white; font-size:18px; }





    • {:$vo}
    • selected >{:$va}
    • selected >{:$vv}
    function Choose(e) { var year=document.getElementById('year'); var month=document.getElementById('month'); var data=document.getElementById('data'); var Y=year.value; var m=month.value; switch(m){ case "2": break; case "4": ; case "6": ; case "9": ; case "11": data.innerHTML="<foreach name='list_data_30' item='vv'><option>{:$vv}</option></foreach>"; break; default: data.innerHTML="<foreach name='list_data_31' item='vv'><option>{:$vv}</option></foreach>"; break; } if(m == 2){ if((Y%4 == 0 && Y%100 != 0)||(Y%400 == 0)){ data.innerHTML="<foreach name='list_data_29' item='vv'><option>{:$vv}</option></foreach>"; }else{ data.innerHTML="<foreach name='list_data_28' item='vv'><option>{:$vv}</option></foreach>"; } } } function ChooseThis(e){ var Y=document.getElementById('year').value; var m=document.getElementById('month').value; var d=document.getElementById('data').value; var text=Y+"-"+m+"-"+d; if(art.dialog.opener.subscribe.time){ art.dialog.opener.subscribe.time.value = text; } art.dialog.close(); }


    控制器中
    public function OpenTime(){
    $now['Y']=date("Y");
    $now['m']=date("m");
    $now['d']=date("d");
    $start="1900";
    $list_year=$this->ThisYear($start,$now['Y']);
    $list_month=$this->ThisMonth();
    $list_data_28=$this->ThisData(28);
    $list_data_29=$this->ThisData(29);
    $list_data_30=$this->ThisData(30);
    $list_data_31=$this->ThisData(31);
    $list_data=$this->NowData($now['Y'],$now['m'],$now['d']);
    $this->assign('now',$now);
    $this->assign('list_year',$list_year);
    $this->assign('list_month',$list_month);
    $this->assign('list_data_28',$list_data_28);
    $this->assign('list_data_29',$list_data_29);
    $this->assign('list_data_30',$list_data_30);
    $this->assign('list_data_31',$list_data_31);
    $this->assign('list_data',$list_data);
    $this->display();
    }

    //年
    function ThisYear($start,$now){
        $length=$now-$start+1;
        $Y=$now;
        for ($i=0; $i < $length ; $i++) { 
            $year[$i]=$Y;
            $Y--;
        }
        return $year;
    }
    //月
    function ThisMonth(){
        for ($i=0; $i < 12; $i++) { 
            $m=$i+1;
            $month[$i]=$m;
        }
        return $month;
    }
    //日
    function ThisData($max){
        for ($d=0; $d < $max; $d++) { 
            $data[$d]=$d+1;
        }
        return $data;
    }
    function NowData($year,$month,$data){
        switch($month){
            case "2": break;
            case "4": ;
            case "6": ;
            case "9": ;
            case "11": $max=30; break;
            default: $max=31; break;
        }
        if($month == 2){
            if(($year%4 == 0 && $year%100 != 0)||($year%400 == 0)){
                $max=29;
            }else{
                $max=28;
            }
        }
        $data=$this->ThisData($max);
        return $data;
    }
    
    点赞 评论
  • qq_42241854
    qq_42241854 2018-07-20 03:22
    点赞 评论
  • th1991
    眯眯眼有杀气 2018-07-20 05:29
    点赞 评论
  • RedFox_Forum
    RedFox_Forum 2018-07-20 07:14

    BootStrap DateTimePicker。。

    点赞 评论
  • BIG_C_GOD
    BIG_C_GOD 2018-07-20 09:19

    <br> function doyear(){<br> var select = document.getElementById(&quot;year&quot;);<br> var thisYear = new Date().getFullYear();<br> for(var i=1900;i&lt;=thisYear;i++){<br> var option = document.createElement(&quot;option&quot;);<br> option.value = i;<br> option.innerText = i;<br> select.appendChild(option);<br> }<br> }</p> <pre><code>function domoth(){ var select = document.getElementById(&quot;month&quot;); for(var i=1;i&lt;=12;i++){ var option = document.createElement(&quot;option&quot;); option.value = i; option.innerText = i; select.appendChild(option); } } function doday(){ var select = document.getElementById(&quot;day&quot;); var selectYear = parseInt(year.options[year.selectedIndex].value); var selectMonth = parseInt(month.options[month.selectedIndex].value); var date = new Date(selectYear,selectMonth,0); for(var i=1;i&lt;=date.getDate();i++){ var option = document.createElement(&quot;option&quot;); option.value = i; option.innerText = i; select.appendChild(option); } } function deleteOldChildNodes(){ var day = document.getElementById(&quot;day&quot;); var node=day.firstChild; var tmpNode; while(node!=day.lastChild){ tmpNode = node.nextSibling; day.removeChild(node); node = tmpNode; } day.removeChild(day.lastChild); } function pageInit(){ doyear(); domoth(); doday(); year.onchange = function(){deleteOldChildNodes();doday();}; month.onchange = function(){deleteOldChildNodes();doday();}; } </code></pre>

    点赞 评论
  • LinGaoNanEr
    LinGaoNanEr 2018-07-20 10:01

    用My97DatePicker插件可以实现

    点赞 评论
  • u011126065
    jasondyoung 2018-07-20 12:19

    你们怕是疯了。
    直接

    点赞 评论

相关推荐