Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Member
    Join Date
    Feb 2010
    Posts
    81
    Member #
    21154
    Hi,

    I'm not sure if this should be in javascript or php but anyway.

    I am designing a website for a client.
    The client doesn't want any maintenance.
    On one page there is a drop down menu with years,
    The years will have to be updated so I am wondering if it is possible to set some sort of code possibly by javascript that tells the website to add a new year to the drop down list every year?
    For example at the start of this year, the code would have added 2010?

    Thanks in Advance.

  2.  

  3. #2
    Senior Member
    Join Date
    Dec 2008
    Posts
    483
    Member #
    17875
    Liked
    1 times
    use either javascript or php.

    id have to lookup the javascript but heres the php

    <select name="yearDD">
    <?php
    $i=date('Y');
    for($i; $i>($i-5); $i--){
    echo '<option value="'.$i.'">'.$i.'</option>';
    }
    ?>
    </select>

    It may need tweaking, but what this basically does is add the current year and the last 5 years to the dropdown e.g
    2010
    2009
    2008
    2007
    2006

    and next year it would be 2011-2007

    You can accomplish the same thing with javascript. if your not worried about server resources, go PHP (considering some clients may not have JS turned on)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:37 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com