Hey all! I am currently using javascript / asp in my online application. I have data which dynamically presents years such as 1999-2003. I need to see if there is a script that can "explode" these years to present 1999, 2000, 2001, 2002, 2003. I cannot for the life of me figure it out. Thanks in advance!
In ASP you can do something like: ' set variables dim yearRange dim startYear dim endYear dim yearsList ' get the year range as a string yearRange = "1999-2003" ' split the string into two values myArray = split(yearRange,"-") ' get the starting and ending years from the two array indexes startYear = myArray(0) endYear = myArray(1) ' use a for next loop to iterate through the ' begin and ending years with years between for x = startYear to endYear if len(yearsList) = 0 then yearsList = x else yearsList = yearsList & ", " & x end if next ' output to screen response.write(yearsList)
Glad to help. That's one way. I'm sure there are others. If anyone has any other methods it would be cool to see them.