Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2005
    Posts
    252
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Populating current year and following year in select drop-down

    How can this be modified so that I do not have to hard-code '07 and '08?

    Code:
    <select class="rez" id="Year" name="Year">
    <option value=07>Year</option>
    <option value=2007>2007</option>
    <option value=2008>2008</option>
    </select>

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    wouldn't it be better to use asp or php for this?

  • #3
    Regular Coder
    Join Date
    Aug 2005
    Posts
    252
    Thanks
    23
    Thanked 0 Times in 0 Posts
    I can use php if that helps?

  • #4
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    ok,
    try this:

    PHP Code:
    <?
    echo "<select class='rez' id='Year' name='Year'>\n";
    echo 
    "<option value='" . (Date('Y') -1) . "'>" . (Date('Y') -1) . "</option>\n";
    echo 
    "<option value='" Date('Y') . "' SELECTED>" Date('Y') . "</option>\n";
    echo 
    "<option value='" . (Date('Y') + 1) . "'>" . (Date('Y') + 1) . "</option>\n";
    echo 
    "<option value='" . (Date('Y') + 2) . "'>" . (Date('Y') + 2) . "</option>\n";
    echo 
    "</select>\n";
    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •