Startdate - Enddate dropdown not working ASP, IIS6

S

sd_eds

I have a startdate-enddate dropdown in asp that works great on my
development machine (XP Pro IIS5) but when I port it over to the web
server (Win Server 2003, IIS6), I do not get the desired results. What
should happen is that the start-end range should show the current
week. Instead, the start-end range defaults to 2 months earlier, when
the page was deployed.

I have added some code below:

<% dim begindate, enddate, startdate %>
<form method="post">
<input name="employee_id" type="hidden" value="<%=
trim(request("employee_id")) %>">
<input name="office_id" type="hidden" value="<%=
trim(request("office_id")) %>">
<select name="weekbegin" onChange="submit()">
<%
startdate = formatDateTime(dateAdd("d", 2 - weekday(now), now),
vbShortDate)
for x = 0 to 365 step 7
begindate = formatDateTime(dateAdd("d", 2 - weekday(now) + x, now),
vbShortDate)
enddate = dateAdd("d", 6, begindate)

if begindate = request("weekbegin") then
%>
<option value="<%= begindate %>" selected><%= begindate & " to " &
enddate %></option>
<%
else
%>
<option value="<%= begindate %>"><%= begindate & " to " & enddate %></
option>
<%
end if
next
%>
</select>
</form>

Any help or insight would be appreciated.

Thanks
 
E

Evertjan.

sd_eds wrote on 03 okt 2007 in microsoft.public.inetserver.asp.general:
I have a startdate-enddate dropdown in asp that works great on my
development machine (XP Pro IIS5) but when I port it over to the web
server (Win Server 2003, IIS6), I do not get the desired results. What
should happen is that the start-end range should show the current
week. Instead, the start-end range defaults to 2 months earlier, when
the page was deployed.

I have added some code below:

<% dim begindate, enddate, startdate %>

Not necessary, unless you use
Option Explicit
first
<form method="post">
<input name="employee_id" type="hidden" value="<%=
trim(request("employee_id")) %>">
<input name="office_id" type="hidden" value="<%=
trim(request("office_id")) %>">
<select name="weekbegin" onChange="submit()">

submit() needs a form object:

onChange="this.form.submit()"
<%
startdate = formatDateTime(dateAdd("d", 2 - weekday(now), now),
vbShortDate)

the weekday() 0 day is system dependent!

use:

Weekday(now, 1)

for x = 0 to 365 step 7
begindate = formatDateTime(dateAdd("d", 2 - weekday(now) + x, now),
vbShortDate)

for x = 2 - weekday(now) to 2 - weekday(now) + 365 step 7
theBegindate = dateAdd("d", x, now)
[see below]
enddate = dateAdd("d", 6, begindate)

You are not dateAdd to a date variable, but to a date string!!!

The date string is system dependent!

try this:

theStartdate = dateAdd("d", 2 - weekday(now), now)
startdate = formatDateTime(theStartdate ,2)

vbShortDate is not defined in vbscript, use number 2

theBegindate = dateAdd("d", 2 - weekday(now) + x, now)
begindate = formatDateTime(theBegindate ,2)

theEnddate = dateAdd("d", 6, theBegindate )
enddate = formatDateTime(theEnddate ,2)
if begindate = request("weekbegin") then

Never use a general request, do a safer request.form()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top