Need to change year

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DavidPr
    New Member
    • Mar 2007
    • 155

    #1

    Need to change year

    Hey,

    I have this code that displays a default year and and from a drop down menu 15 additional years from the default year.

    The default year is 2000. I'd like to change it to the current year (2008) if it's possible and the fifteen additional years start from 2008.

    Thanks.

    [PHP] output += '</select> \n<select id="year">\n';
    for(var i=0;i<=15;i++) {
    n = (i<10)? '0'+i:i;
    output += '<option value="20'+n+'" >20'+n+' </option>\n';
    }
    output += '</select> <a href="javascrip t:jumpTo()"><im g src="/calendar/images/calGo.gif" alt="go" />Go</a> <a href="javascrip t:hideJump()">< img src="/calendar/images/calStop.gif" alt="close" />Close</a>';
    jump.innerHTML = output;
    document.body.a ppendChild(jump );
    }
    [/PHP]
  • DavidPr
    New Member
    • Mar 2007
    • 155

    #2
    OK got it.

    [PHP]output += '</select> \n<select id="year">\n';
    for(var i=8;i<=23;i++) {
    n = (i<10)? '0'+i:i;
    output += '<option value="20'+n+'" >20'+n+' </option>\n';
    }
    output += '</select> <a href="javascrip t:jumpTo()"><im g src="/calendar/images/calGo.gif" alt="go" />Go</a> <a href="javascrip t:hideJump()">< img src="/calendar/images/calStop.gif" alt="close" />Close</a>';
    jump.innerHTML = output;
    document.body.a ppendChild(jump );
    }[/PHP]
    Thanks

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Instead of that, get the current year automatically, so you don't have to keep changing the code each year.

      Comment

      Working...