js 每个月有多少天算法

function change_date ()
            {
              
var month=document.getElementById('start_month');
              
                
var  month_temp=month.value.split('月');
               
var  year=document.getElementById('start_year') ;
               
var year_temp=year.value.split('年');
               
var date ;
                
if (month_temp[0]=='1'|| month_temp[0]=='3'|| month_temp[0]=='5|| month_temp[0]=="7" || month_temp[0]=="8"  || month_temp[0]=="10"   || month_temp[0]=="12" )
                 {  date
=31 ;
                  }
                  
if (month_temp[0]=='4|| month_temp[0]=='6'   || month_temp[0]=='9 '  || month_temp[0]=='11' )
                  {
                  date
=30;
                  }
                 
//  window.alert (month_temp[0]);
                 
                  
if (month_temp[0]=='2' )
                  { 
                    
if(year_temp[0]%100==0)
                    { 
                      
if (year_temp[0]%400==0)
                         {
                           date
=29 ;
                         }
                         
else
                         {
                        date
=28;
                          }
                          
                    } 
                    
else
                    {
                       
if(((year_temp[0]%100)%4)==0)
                          {
                           date
=29 ;
                          }
                          
else
                          {  
                            date
=28;
                          } 
                     }  
                  }
                  
                    
var temp_date =document.getElementById('start_day');
                 
for(i=1;i<date;i++)
                 {
                      
var add_date=document.createElement("OPTION");
                        add_date.text
=i+'日';
                        add_date.value
=i+'日';
                        temp_date.add(add_date);
                           
                   }   
                  
            }

posted on 2005-03-26 17:55  gwazy  阅读(1288)  评论(0编辑  收藏  举报

导航