Forums
This topic is locked
Selecting current hour in dropdown list
23 Jan 2006 12:07:05 Tom Theys posted:
Hi,I'm currently working on an ASP wabsite where the user is able to adjust date and time of a post with a dropdown list.
Everyhting works, but I have some problems with the hour.
For day, month and year I use this code, works perfect:
<font color=blue>
<select name="u_day" class="form_field">
<% for counter = 1 to 31 %>
<option <%
if counter = day(rsPosts.Fields.Item("PostDate".value) then %>
selected
<% end if %>
value="<%= counter %>">
<%= counter %></option>
<% next %>
</select>
<select size="1" name="u_month" class="form_field">
<% for counter = 1 to 12 %>
<option <%
if counter = month(rsPosts.Fields.Item("PostDate".value) then %> selected <% end if %> value="<%= counter %>"><%= MonthName(counter) %></option>
<% next %>
</select>
<select size="1" name="u_year" class="form_field">
<% for counter = 2005 to 2010 %>
<option <%
if counter =year(rsPosts.Fields.Item("PostDate".value) then %> selected <%
end if %> value="<%= counter %>"><%= counter %></option>
<% next %>
</select>
</font id=blue>
Now for the hour I'm using this, but sometimes it does not work, so this isn't the way to do it.
<font color=blue>
<select name="u_time" class="form_field">
<% for counter = 8 to 22 %>
<option <%
if counter = hour(rsPosts.Fields.Item("PostDate".value) then %> selected <% end if %> value="<%= counter %>:00:00"><%= counter %>:00:00</option>
<% next %>
</select>
</font id=blue>
does anyone knows how to work with the hours?
thanks!
Replies
Replied 25 Jan 2006 16:13:28
25 Jan 2006 16:13:28 Tom Theys replied:
I'm also using a javascript function to get the dates from the fields
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="form1" onSubmit="GetDate()">
the javascript GetDate():
<script language="JavaScript">
<!--
function GetDate() {
document.form1.PostDate.value = document.form1.u_day.value + '/' + document.form1.u_month.value + '/' + document.form1.u_year.value + ' ' + document.form1.u_time.value;
}
//-->
</script>
maybe I'm doing something wrong here
and the variables
<%
u_date=request.form("u_date"
u_month=request.form("u_month"
u_day=request.form("u_day"
u_year=request.form("u_year"
u_time=request.form("u_time"
%>
If I choose 'edit post' the hour comes correct in the dropdown list, but when I choose update, even when I leave the current hour selected, it removes the hour in the DB date field, only the date get's updated and the time is deleted.
Edited by - tothprod on 25 Jan 2006 16:14:51
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="form1" onSubmit="GetDate()">
the javascript GetDate():
<script language="JavaScript">
<!--
function GetDate() {
document.form1.PostDate.value = document.form1.u_day.value + '/' + document.form1.u_month.value + '/' + document.form1.u_year.value + ' ' + document.form1.u_time.value;
}
//-->
</script>
maybe I'm doing something wrong here
and the variables
<%
u_date=request.form("u_date"
u_month=request.form("u_month"
u_day=request.form("u_day"
u_year=request.form("u_year"
u_time=request.form("u_time"
%>
If I choose 'edit post' the hour comes correct in the dropdown list, but when I choose update, even when I leave the current hour selected, it removes the hour in the DB date field, only the date get's updated and the time is deleted.
Edited by - tothprod on 25 Jan 2006 16:14:51
Replied 26 Jan 2006 11:47:41
26 Jan 2006 11:47:41 Tom Theys replied:
Ok, found it!
I had a code in my update function that converted the date to an ISO date, only the day, month and year was converted, silly me <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
I had a code in my update function that converted the date to an ISO date, only the day, month and year was converted, silly me <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>