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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Comparing drop down values

    I want people to enter a start month and year and an end month and year. I want to create a script that ensures that the end month and year is not before the start month and year. My thought was to have a drop down menu for start month, and a drop down for start year, and the same for the end month/year. Does anyone have a script that will compare the years to ensure the end is greater than the start....and if its hte same, then look at the month to ensure that the end month is greater than the start month? Thanks!

  • #2
    Senior Coder
    Join Date
    Jul 2005
    Location
    New York, NY
    Posts
    1,084
    Thanks
    4
    Thanked 19 Times in 19 Posts
    Code:
    function compareStuff(startYearSelect, startMonthSelect, endYearSelect, endMonthSelect)
    {
      if (Number(startYearSelect.value) < Number(endYearSelect.value))
      {
         return true;
      }
      else if (Number(startYearSelect.value) == Number(endYearSelect.value) && Number(startMonthSelect.value) < Number(endMonthSelect.value))
      {
        return true;
      }
      else
      {
        return false;
      }
    }


  •  

    Posting Permissions

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