Reply
Help with Years...
Old 01-29-2007, 11:04 AM Help with Years...
Junior Talker

Posts: 3
Hi there...I am creating a drop-down with years. Now I need to display 10 years starting from this year so 2007, 2008, 2009...2017. So next year the drop down will show 2008, 2009,....2018...I think year(Date+1) is pretty stupid to try...but I did and offcourse it doesnt work)

<select name=ExpirationYear class=fields>

<option></option>
<option value="Sign In"><%=Year(Date) %></option>
<option value="Sign In From Unpaid break"><%=Year(Date+1) %></option>
<option value="Sign Out For Unpaid break">2009</option>
<option value="Sign Out">2010</option>
<option value="Sign In">2011</option>
<option value="Sign In From Unpaid break">2012</option>
<option value="Sign Out For Unpaid break">2013</option>
<option value="Sign Out">2014</option>
<option value="Sign In">2015</option>
<option value="Sign In From Unpaid break">2016</option>
<option value="Sign Out For Unpaid break">2017</option>
<option value="Sign Out">2018</option>

</select>

Any clues???
terp_in_umcp is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 01-29-2007, 11:17 AM Oops...I got it:)
Junior Talker

Posts: 3
Hey there...sorry for posting too soon...looks like i got the answer...silly me...its <%=Year(Date)+2%>
terp_in_umcp is offline
Reply With Quote
View Public Profile
 
Old 01-30-2007, 04:46 AM Re: Help with Years...
bbutton's Avatar
Experienced Talker

Posts: 43
Name: Bill Button
Location: Reading,UK
Hi,

You can also use the DateAdd function, I know you have already solved the problem. But its a function worth nowing.

http://www.w3schools.com/vbscript/func_dateadd.asp
bbutton is offline
Reply With Quote
View Public Profile Visit bbutton's homepage!
 
Old 02-05-2007, 03:06 AM Re: Help with Years...
saadatshah's Avatar
Extreme Talker

Posts: 216
Name: Syed Saadat Ali
Location: Lahore, Pakistan
My suggestion is write a function which can accept two parameters StartYear & EndYear and generate a dropdown. Use DateAdd function. This would be more flexible.
__________________
Traffic School - Driver Ed - Defensive Driving - Texas Defensive Driving - Online Traffic School - Defensive Driving Course
If you have knowledge, let others light their candles in it.
saadatshah is offline
Reply With Quote
View Public Profile Visit saadatshah's homepage!
 
Old 02-06-2007, 10:49 AM Re: Help with Years...
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
First off, while your solution is "correct", it's not the optimal. Try to use ASP functions as minimally as you can as every call to a built-in function does take up some server resource.

Do something like this instead:
Code:
Dim Start_Year, End_Year, i
Start_Year = Year (Date)
End_Year = Start_Year + 10
for i = Start_Year to End_Year
     Response.Write "<option>" & i & "</option>"
Next
One call to retrieve the year, one call to retrieve the date, no other functions necessary.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to Help with Years...
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14875 seconds with 13 queries