473,406 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Display Date in Text Box on ASP page

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

Jul 23 '05 #1
5 7472
Lee
ts******@gmail.com 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.

Jul 23 '05 #2
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.

Jul 23 '05 #3
JRS: In article <11**********************@f14g2000cwb.googlegroups .com>
, dated Tue, 10 May 2005 13:57:42, seen in news:comp.lang.javascript,
ts******@gmail.com 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.
Jul 23 '05 #4
Try this (works on my form)

// Right after body tag

<%
dim todaysDate

todaysDate = date()
%>

// Form Field

<input type="text" name="tDate" size="25" value="<%=todaysDate %>">
Jul 23 '05 #5
Ri**@NeedsHelp.com 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
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Scott Vercuski | last post by:
Hello All, I'm having a problem saving/displaying multiple lanaguages on an ASP page. Here's the general problem I'm having. I have an admin area of a website that allows a user to enter items...
4
by: dmiller23462 | last post by:
I'm trying to create a submission page for users to request PC/LAN Access....If they select "Yes" in the field asking about if they need Non Standard Software, I want several other HTML fields to...
11
by: Jim | last post by:
I have been using the javascript below on a web page since last August to show the "Site updated" month only minus a month, which has been very successful, but January is showing a "undefined 2004"...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
2
by: Benedict Teoh | last post by:
I created a dropdownlist containing day, month and year field and expose a property to assign a date. When I call from a aspx page and assign the value, the new date is not displayed until a submit...
5
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page...
3
by: Pacer Dawn | last post by:
I have a web control that takes a date input. There are two types of validation I want to do on this: 1) validate that the date input is in the proper format, and display a message if otherwise...
1
by: rbinington | last post by:
Hi, I am trying to write a DNN module that has the ability to insert articles into an article repository. I want the users to be able to move pages around and enter text into the FCKEditor. I...
4
by: remya1000 | last post by:
I'm using ASP with MSAccess as database. i have two text box and one button in my page. and i need to select dates from calander and display it in this two textbox. but i dont need to place a...
1
by: amritranjan | last post by:
How to retrive image file from MS access database and display this in another JSPpage -------------------------------------------------------------------------------- This is my Jsp code for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.