Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Display Date in Text Box on ASP page

Reply
Thread Tools

Display Date in Text Box on ASP page

 
 
tsmith81@gmail.com
Guest
Posts: n/a
 
      05-10-2005
Ok. I have an ASP page that send data to a database. One of the fields
is "Date" (no quotes). The form name is FrontPage_Form1. I would like
the Date field to auto populate. So, I did some research and the only
thing that I could come up with that worked was this:

<script>
function upDate() {
FrontPage_Form1.Date.value=new Date();



}

setInterval('upDate()',1000);
</script>


While this is good, I need the date to be displayed as MM/DD/YY or
MM/DD/YYYY. Help me please....

Thanks in advance,

Tim

 
Reply With Quote
 
 
 
 
Lee
Guest
Posts: n/a
 
      05-10-2005
said:
>
>Ok. I have an ASP page that send data to a database. One of the fields
>is "Date" (no quotes). The form name is FrontPage_Form1. I would like
>the Date field to auto populate. So, I did some research and the only
>thing that I could come up with that worked was this:
>
><script>
>function upDate() {
>FrontPage_Form1.Date.value=new Date();
>
>
>
>}
>
>setInterval('upDate()',1000);
></script>
>
>
>While this is good, I need the date to be displayed as MM/DD/YY or
>MM/DD/YYYY. Help me please....


Since this is an ASP page, you should be filling in the date
in your ASP code on the server side, where you know that
scripting is enabled and that the system clock is set to the
correct year.

 
Reply With Quote
 
 
 
 
tsmith81@gmail.com
Guest
Posts: n/a
 
      05-10-2005
Forgive my ignorance at the moment... I have been searching for my
answer to this for 8 hours. Can you tell me how I can do this? Thank
you.

 
Reply With Quote
 
Dr John Stockton
Guest
Posts: n/a
 
      05-11-2005
JRS: In article < .com>
, dated Tue, 10 May 2005 13:57:42, seen in news:comp.lang.javascript,
posted :
>Ok. I have an ASP page that send data to a database. One of the fields
>is "Date" (no quotes). The form name is FrontPage_Form1. I would like
>the Date field to auto populate. So, I did some research and the only
>thing that I could come up with that worked was this:
>
><script>
>function upDate() {
>FrontPage_Form1.Date.value=new Date();
>
>
>
>}
>
>setInterval('upDate()',1000);
></script>
>
>
>While this is good, I need the date to be displayed as MM/DD/YY or
>MM/DD/YYYY. Help me please....


It's less good than you think, unless you have omitted relevant
information, since the text string format obtained that way is not well
defined.

Only chronologically backward locations still use FFF dates; it is
recommended that ISO 8601 / ANSI X3.30-1985(R1991), FIPS PUB 4-1, 4-2
be followed. Use YYYY-MM-DD or YYYY/MM/DD, in order that there can be
no misunderstanding.

Note that setInterval(..., 1000) does not necessarily update every
second. However, one can get an update every second (unless the client
CPU is pre-empted) by using setTimeout(..., X), see via below.

If you need to know the date and time by the client computer, can you
not get it loaded into ...Date.value as part of the Submit process? If
you only need the correct date and time, that's better done on the
server - though the possible consequences of using a date and time that
the user may think are wrong should be considered.

One should read a newsgroup's FAQ before posting. See below.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      05-15-2005
wrote:
^^^^^^^^^^^^^^^^^^
You want to refrain from spoiling namespaces:
<http://www.cablevision.com/index.jhtml?pageType=terms>

> Try this (works on my form)
>
> // Right after body tag


Not required. The first snippet may be located anywhere before the
second snippet is parsed. ASP does not care if it is HTML or FUBAR
you are sending to the client.

> <%
> dim todaysDate
>
> todaysDate = date()
> %>
>
>
>
> // Form Field
>
> <input type="text" name="tDate" size="25" value="<%=todaysDate %>">

^^^^^^^^^^^
not necessary, it's the default

Works with VBScript. As this is a J(ava)Script/ECMAScript group,
here's the JScript ASP solution (probably without any user-defined
date formatting as well):

<%@ LANGUAGE = "JScript" %>
<%
var todaysDate = Date();
%>
...
<input name="tDate" size="25" value="<%= todaysDate %>">


PointedEars
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
div box questions; float text around a box, fit box to image size Gnarlodious HTML 4 05-05-2010 11:30 AM
I have one ASP.NET Page. It's for display customer information. Now I want this page to handle the function "Edit" and "Display", Is it possible? Benny Ng ASP .Net 1 01-04-2007 08:00 PM
display text in text box nikou_70@yahoo.com ASP General 1 12-07-2005 05:58 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Display text in text box - should be simple, doesn't work Jim Owen ASP .Net 1 07-24-2003 05:37 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57