Print Page | Close Window

Selecting current hour in dropdown list

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=18126
Printed Date: 29 March 2026 at 6:28pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Selecting current hour in dropdown list
Posted By: toth
Subject: Selecting current hour in dropdown list
Date Posted: 25 January 2006 at 2:59pm
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:
 
<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>
 
Now for the hour I'm using this
 
<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>
 
I'malso using a javascript functio 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.



Replies:
Posted By: toth
Date Posted: 26 January 2006 at 9:36am
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 Smile



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net