Re: [問題] 樂多的每月記事

看板Blog作者 (小兔加油!!)時間19年前 (2006/12/11 23:31), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串5/5 (看更多)
也是下拉式選單 不過是用JavaScript寫的 使用方式只要把剛開始那幾行const變數的值改一改就可以了 function以下就不用管了 --- <script language="JavaScript"> const startYear = 2004; // 開始年份 const startMonth = 10; // 開始月份 const endYear = 2006; // 結束年份 const endMonth = 12; // 結束月份 const account = 'scchiang'; // 你的使用者名稱 const defaultString = '---'; // 一開始顯示的字串 const useChinese = 1; // 用中文就填1, 用英文就填0 function gotoMonthlyArchive(month) { if (month != "none") { var url = "http://blog.roodo.com/" + account + "/archives/" + month + ".html"; window.open(url, "_self", ""); } } const monthStr = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; const monthNum = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]; var year = endYear; var month = endMonth; var i; var output = '<select onChange="javascript: gotoMonthlyArchive(this.value);">'; output += '<option value="none">' + defaultString + '</option>'; output += '<optgroup label="' + year + '">'; while ((year > startYear) || (year == startYear && month >= startMonth)) { i = month - 1; output += '<option value="' + year + '-' + monthNum[i] + '">'; if (useChinese) { output += year + ' 年 ' + month + ' 月'; } else { output += monthStr[i] + ', ' + year; } output += '</option>'; if (month == 1) { month = 12; year--; output += '</optgroup>'; output += '<optgroup label="' + year + '">'; } else { month--; } } output += '</optgroup>'; output += '</select>'; document.write(output); </script> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.161.7.16 ※ 編輯: shihchi 來自: 218.161.7.16 (12/11 23:47) ※ 編輯: shihchi 來自: 218.161.7.16 (12/11 23:50) ※ 編輯: shihchi 來自: 218.161.7.16 (12/11 23:55)
文章代碼(AID): #15VNd80- (Blog)
文章代碼(AID): #15VNd80- (Blog)