Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Selecting current hour in dropdown list
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Selecting current hour in dropdown list

 Post Reply Post Reply
Author
toth View Drop Down
Newbie
Newbie


Joined: 25 January 2006
Location: Belgium
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote toth Quote  Post ReplyReply Direct Link To This Post Topic: Selecting current hour in dropdown list
    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.
Back to Top
toth View Drop Down
Newbie
Newbie


Joined: 25 January 2006
Location: Belgium
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote toth Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.