欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

下拉框时间显示

发布时间:2025/6/15 43 豆豆
生活随笔 收集整理的这篇文章主要介绍了 下拉框时间显示 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

      

脚本说明:   把如下代码加入<body>区域中

 <FORM>

<SELECT NAME="dates" SIZE=1>

<SCRIPT LANGUAGE="JavaScript">

//--------------------------------------------

//By mattias.sjoberg@swipnet.se 26/7-97

// The JavaScript Planet

// http://www.geocities.com/SiliconValley/7116

// You're welcome to use/edit this script, // just keep the comments and drop me a note.

//--------------------------------------------

        today = new Date();   

      thismonth = today.getMonth() + 1;    

     thisyear = today.getYear();        

thisday = today.getDate();

        maxdays=31;//default

        // months with 30 days      

   if (thismonth==4 || thismonth==6 || thismonth==9 || thismonth==11)  

       {              

   maxdays=30   

      }

        // february, leap year     

    if (thismonth==2)    

     {               

  // feb             

    if ((thisyear/4)!=parseInt(thisyear/4))      

           {                  

       maxdays=28     

            }             

    else            

     {             

            //leap year       

                  maxdays=29       

          }        

}

        thismonth = "" + thismonth

        if (thismonth.length == 1)    

     {              

   thismonth = "0" + thismonth;    

     }

        for (var theday = 0; theday <= maxdays; theday++)  

       {             

    if (theday == 0)          

       {                 

        document.write ("<OPTION SELECTED> "+ thisday + "-" + thismonth + "-" + thisyear )              

           document.write ("<OPTION> ========")        

         }

    

 

      else        

         {          

               var thed = "" + theday          

               if (thed.length == 1)        

                 {               

                  thed = "0" + thed;            

             }                    

     document.write ("<OPTION> " + thed + "-" + thismonth + "-" + thisyear)       

          }     

    }

</SCRIPT> </SELECT> </FORM>

 

 

 

转载于:https://www.cnblogs.com/fzm99/p/3330428.html

总结

以上是生活随笔为你收集整理的下拉框时间显示的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。