/    Sign up×
Community /Pin to ProfileBookmark

Dropdown List of Dates by Day of the Week

Hi,

I only know basic Javascript and can’t figure out this date script.

I need to create a dropdown that will list the next 8 Wednesdays in the format MM/DD/YY.

I would appreciate any script help or being pointed in the right direction!

(This is part of an ASP app so also let me know if you think it’d be easier to accomplish in vbscript?)

Thanks!!

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@so_is_thisDec 21.2006 — Yes, best if done in ASP. Post to that forum.
Copy linkTweet thisAlerts:
@so_is_thisDec 21.2006 — Well, here's the answer anyways:
[code=html]
<% @Language=VBScript %>
<% Option Explicit %>
<%
Function DateOfFirstWeekDay(dateObj, WhichDay)
Dim TempDay
TempDay = WeekDay(DateSerial(Year(dateObj), Month(dateObj), 1))
If TempDay > WhichDay Then
TempDay = 1 + ((WhichDay + 7) - TempDay)
Else
TempDay = 1 + (WhichDay - TempDay)
End If
DateOfFirstWeekDay = TempDay
End Function
'
Dim curdate, tmpdate, x
curdate = Date()
tmpdate = DateSerial(Year(curdate), Month(curdate), DateOfFirstWeekDay(tmpdate, vbWednesday))
Do Until tmpdate > curdate
tmpdate = DateAdd("d", 7, tmpdate)
Loop
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Populate Dropdown List</title>
</head>

<body>
<form>
<p><select name="seldates" size="1">
<% For x = 1 To 8 %>
<option><%=FormatDateTime(tmpdate, vbShortDate)%></option>
<% tmpdate = DateAdd("d", 7, tmpdate)
Next
%>
</select></p>
</form>
</body>
</html>[/code]
Copy linkTweet thisAlerts:
@michellewauthorDec 21.2006 — That works perfectly

Thanks!
Copy linkTweet thisAlerts:
@so_is_thisDec 21.2006 — Salud!
×

Success!

Help @michellew spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...