* 您消费的时间
* 您消费的时间 2007 2008 2009 2010 2011 2012 2013 年 01 02 03 04 05 06 07 08 09 10 11 12 月 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 日 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 点 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 分
<script> <br>var today=new Date()//Define a time object<br>var yy=today.getYear() <br> var mm=today.getMonth() 1 <br>var dd=today.getDate() <br>var h=today.getHours()//define hours <br>var m=today.getMinutes()//define minutes <br>document.getElementById("years").options(yy-2007).selected=1 <br>document.getElementById("months").options(mm-1).selected=1 <br>document.getElementById ("days").options(dd-1).selected=1 <br>document.getElementById("hours").options(h).selected=1 <br>document.getElementById("mins").options( m).selected=1 <br></script>
The third method: cannot But the programming idea is OK. If it is used formally, it is recommended to use the second method
New Document
< script>
function setDay(obj){
obj = obj.form;
var years=parseInt(obj.years.options[obj.years.selectedIndex].value);
var months= parseInt(obj.months.options[obj.months.selectedIndex].value);
if(obj.years.selectedIndex==0 || obj.months.selectedIndex==0)return;
var lastday = monthday(years,months);
var itemnum = obj.days.length;
if (lastday - 1 < obj.days.selectedIndex)
{
obj.days.selectedIndex = lastday - 1;
}
obj.days.length = lastday;
for(cnt = itemnum 1;cnt <= lastday;cnt )
{
obj.days.options[cnt - 1].text = cnt;
}
}
function monthday(years,months)
{
var lastday = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if (((years % 4 == 0) && (years % 100 != 0)) || (years % 400 == 0))
{
lastday[1] = 29;
}
return lastday[months - 1];
}
function forto(ff,to)
{
document. write('
');
for(var ii=ff; ii<=to; ii )
document.write('
' ii ' ');
}
function a()
{
alert(document.all("years").value "Years " document.all("months").value "month" document.all("days").value "day") ;
}