NewsRhzhi | 先创资讯 | 旧版入口
rhzhi.net
网站首页 | NewsRhzhi | 先创资讯 | 操作系统 | 工具软件 | 办公软件 | 网站设计 | 组网专栏 | 平面设计 | 多 媒 体 | 程序开发 | 硬件资料 | 聊天软件
您现在的位置: 先创网 >> 网站设计 >> 相关资料 >> 文章正文
在下拉式的Form框中显示时间
天极软件
2005-11-24 10:27:00文/佚名
    

要完成此效果把如下代码加入到<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>

打印此页 投稿与建议 返回顶部
栏 目 索 引
软件应用 SOFTWARE
Win XP | NT/2003
Win2000 | DOS/Win9x
PowerPoint | Office
Excel | Word
网络软件 | 实用软件
媒体软件 | 系统软件
常用软件 | 办公软件
聊天软件 | 网络安全
新软试用 | Vista
设计在线 DESIGN
Dreamweaver | 3DMax
Photoshop | Flash
平面设计 | 网页设计
多 媒 体 | 精品画廊
精彩专区 SPECIAL
Q Q 专区 | 热门专题
组网玩网 | 程序开发
应用集锦 |
相关文章
关于我们 - 联系方式 - 合作伙伴 - 网站大事记 - 网站地图 - 我要投稿
Copyright ©1997-2008 先创网 All Rights Reserved.
先创科技 版权所有