js获得当前日期并 显示

                                                        <select id="select1" name="select1">
                                                            <option value="2007" selected>2007</option>
                                                            <option value="2008">2008</option>
                                                            <option value="2009">2009</option>
                                                            <option value="2010">2010</option>
                                                        </select>                         
                                <script language="javascript">
                                    //对日期选择部分进行赋值
                                    tick  =  new  Date();
                                    hours  =  tick.getHours();
                                    month  =  tick.getMonth() + 1;
                                    day  =  tick.getDate();
                                    year  =  tick.getYear();
                                    document.getElementById("select1").selectedIndex = year-2007;
                                    document.getElementById("select2").selectedIndex = month-1;
                                    document.getElementById("select3").selectedIndex = day-1;
                                    document.getElementById("select4").selectedIndex = hours-1;
                                </script>
posted @ 2008-01-08 11:35  MangaGo  阅读(1956)  评论(0编辑  收藏  举报