2013-01-09 48 views
-2

我有這個JavaScript代碼,我想這應該是代碼必須改變的地方。修改javascript以讓顯示前幾年

if (this.options.showYear) { 
      str += '<select tabindex="'+this.tabIndex+'" class="' + this.options.yearClass + '">'; 
      if (this.options.yearOrder == 'desc'){ 
       for (var y = this.options.yearStart; y > (this.options.yearStart - this.options.yearRange - 1); y--){ 
        str += this.addOption(y,y,parseInt(this.calendarYear)); 
       } 
      } else { 
       for (var y = this.options.yearStart; y < (this.options.yearStart + this.options.yearRange + 1); y++){ 
        str += this.addOption(y,y,parseInt(this.calendarYear)); 
       } 
      } 

日曆目前只顯示2013以上,我至少需要2012 .. 請幫助我! 感謝

dayChars: 1, 
     monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 
     dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], 
     daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], // Leap year is added later 
     format: 'yyyy/mm/dd',           // How the output looks after selection 
     yearStart: (new Date().getFullYear()),      // Default starting year for dropdown options is 5 years ago 
     yearRange: 10,             // Show a 10 year span 
     yearOrder: 'asc',            // Counting up in years 
     startDay: 7 
+0

您的上下文對象具有propertie'options'它也有一個'yearStart' propertie,將其更改爲您的需求 – C5H8NNaO4

+0

多一點背景請。 「選項」在哪裏定義? – ATOzTOA

+0

信息太少。這是一個猜謎遊戲。此外,你不會顯示任何努力或見解。 – Amberlamps

回答

0

變化在你的選項

yearStart: (new Date().getFullYear()), 

yearStart: (new Date().getFullYear() - 1), // or any number of years you want to go back 
+0

謝謝,非常感謝你:) –

+0

不客氣:) –

0
if (this.options.showYear) { 
    str += '<select tabindex="'+this.tabIndex+'" class="' + this.options.yearClass + '">'; 

    this.options.yearStart -= 1; 

或更改options.yearStart至2012年,而不是2013年(當年)

+0

這不會起作用... 請看我更新的問題.. –

0

試着這麼做:

if(this.options.yearStart >= 2013) { 
    this.options.yearStart = 2012; 
} 

或者

dayChars: 1, 
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], 
daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], // Leap year is added later 
format: 'yyyy/mm/dd',           // How the output looks after selection 
yearStart: ((new Date().getFullYear()) < 2013 ? (new Date().getFullYear()) : 2012), // Default starting year for dropdown options is 5 years ago 
yearRange: 10,             // Show a 10 year span 
yearOrder: 'asc',            // Counting up in years 
startDay: 7 
0
yearStart: ((new Date().getFullYear()) - 1),