HTML元件(HTMLCOMPONENTS)之四編寫日曆(2)(轉)

post0發表於2007-08-15
HTML元件(HTMLCOMPONENTS)之四編寫日曆(2)(轉)[@more@]

===編寫日曆一===

如果指定的年數可以被4整除,那麼leapYear()函式將返回“true”,否則返回”false“:

function leapYear(year) {

if (year % 4 == 0) // basic rule

return true; // is leap year

/* else */ // else not needed when statement is "return"

return false; // is not leap year

}

getMonthName()函式返回指定月份的名字:

function getMonthName(month) {

// create array to hold name of each month

var ar = new Array(12);

ar[0] = "January";

ar[1] = "February";

ar[2] = "March";

ar[3] = "April";

ar[4] = "May";

ar[5] = "June";

ar[6] = "July";

ar[7] = "August";

ar[8] = "September";

ar[9] = "October";

ar[10] = "November";

ar[11] = "December";

// return name of specified month (parameter)

return ar[month];

}

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8225414/viewspace-957381/,如需轉載,請註明出處,否則將追究法律責任。

相關文章