473,503 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Date/Time to an HTML form? - Request_Information_b.html (0/1)

I'm trying to add a date and time to an html form, but I'm having a
bit of trouble getting it working. Any suggestions?

Thanks!
~ David (merlin001_at_gmail_dot_com)
Jun 20 '07 #1
8 35959
Lee
David <merlin001 said:
>
I'm trying to add a date and time to an html form, but I'm having a
bit of trouble getting it working. Any suggestions?
This is a text newsgroup.
Please don't post encoded attachments.
If you want to post html, just copy and paste it into your message.
If it's too long, or you don't want to strip out enough whitespace
to make it readable when posted, put it on the web and post an URL.

<html>
<body>
<p>This won't hurt any decent newsreader</p>
</body>
</html>
--

Jun 20 '07 #2
me
Sorry, I'm still learning newsgroups. Okay, the text follows. I'm just trying
to get a date/time as a field in the submitted form.

<html><head><title>Request Information</title>

<script type="text/javascript">

var currentHour = "";

var currentMinute = "";

var currentSeconds = "";

var DateAndTime = "";

var AMPM = "";

var currentTime = "";

var currentDate = "";

var currentMonth = "";

var newMonth = "";

var currentDay = "";

var currentYear = "";

function getCurrentTime() {

DateAndTime = new Date();

currentDate = getCurrentDate();

currentHour = DateAndTime.getHours();

if (currentHour >= 12)

{ AMPM = "PM"; currentHour = currentHour - 12; }

else if (currentHour == 0)

{ AMPM = "AM"; currentHour = 12; }

else

{ AMPM = "AM"; }

currentMinute = DateAndTime.getMinutes();

currentSeconds = DateAndTime.getSeconds();

if (currentSeconds < 10)

{ currentSeconds = "0" + currentSeconds; }

currentTime = currentHour + ":" + currentMinute + ":" + currentSeconds +
" " + AMPM;

return dateAndTime; }

function getCurrentDate() {

currentMonth = DateAndTime.getMonth();

currentDay = DateAndTime.getDay();

currentYear = DateAndTime.getFullYear();

switch (currentMonth) {

case 0: { newMonth = "January"; break; }

case 1: { newMonth = "February"; break; }

case 2: { newMonth = "March"; break; }

case 3: { newMonth = "April"; break; }

case 4: { newMonth = "May"; break; }

case 5: { newMonth = "June"; break; }

case 6: { newMonth = "July"; break; }

case 7: { newMonth = "August"; break; }

case 8: { newMonth = "September"; break; }

case 9: { newMonth = "October"; break; }

case 10: { newMonth = "November"; break; }

case 11: { newMonth = "December"; break; } }

thisDate = newMonth + " " + currentDay + ", " + currentYear;

return thisDate; }

</script>

</head>

<body bgcolor="black" text="white">

<h1 align="center">Request Information</h1>

<form method="post" action="mailto:pe****@domain.com">

<h3>Contact Information:</h3>

First name:<input type="text" name="firstname"><br />

Last name:<input type="text" name="lastname"><br />

Company:<input type="text" name="company"><br />

Address 1:<input type="text" name="address1"><br />

Address 2:<input type="text" name="address2"><br />

City:<input type="text" name="city">

Zip Code:<input type="text" name="zipcode"><br />

Phone Number:<input type="text" name="phone"><br />

E-Mail Address:<input type="text" name="email"><br /><br />

<input type="hidden" name="dateTime" value="getCurrentTime()">

<input type="submit" value="Submit" />

<input type="reset" value="Reset" />

</form>

</body>

</html>
--
--------------------------------- --- -- -
Posted with NewsLeecher v3.9 Beta 1
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -

Jun 20 '07 #3
On Jun 20, 3:05 pm, me (m...@somewhere.com) wrote:
Sorry, I'm still learning newsgroups. Okay, the text follows. I'm just trying
to get a date/time as a field in the submitted form.
[...]
<input type="hidden" name="dateTime" value="getCurrentTime()">
You can insert script[1] as the value of attributes that represent
intrinsic event handlers such as onclick, onfocus, onblur, etc. The
HTML specification lists those that are appropriate for each
element[2]. Putting script into some other attribute makes its value
the literal characters, the script isn't executed.

Presumably you'd like to get the time that the user submitted the
form. Why not just get that when the server gets the post request? No
need for script, hoping that the user has their system clock set
correctly or dealing with time zones.

1. Basic HTML Data Types - Script
<URL: http://www.w3.org/TR/html4/types.html#type-script >

2. W3C HTML 4 specification
<URL: http://www.w3.org/TR/html4/ >
--
Rob

Jun 20 '07 #4
In comp.lang.javascript message <v78h735l6bi5am6cr7sfssp749vljhk20t@4ax.
com>, Tue, 19 Jun 2007 20:37:59, David <merlin001@?.?.com.invalid>
posted:
>I'm trying to add a date and time to an html form, but I'm having a
bit of trouble getting it working. Any suggestions?
You should read the newsgroup FAQ with care - especially with an e-
address like "yours".

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jun 20 '07 #5
In comp.lang.javascript message <46***********************@unlimited.new
shosting.com>, Wed, 20 Jun 2007 05:05:14, me@?.?.invalid posted:
>Sorry, I'm still learning newsgroups. Okay, the text follows. I'm just trying
to get a date/time as a field in the submitted form.
Only really silly people use the 12-hour clock in internal data
processing. The generic adjective for them is "Americans". Granted,
/hoi polloi/ use it in other countries too; but at least they generally
understand the 24-h clock.

Your organisation should either engage a trained Javascript programmer,
or buy you a copy of "Javascript for Dummies". You clearly have a
grossly inadequate understanding of Javascript programming.

The following, with "text" restored to "hidden", will do substantially
what you need, loading the field with a recognisable date[*].

<input type="text" ID="dateTime" size=33>
<script>
document.getElementById("dateTime").value = new Date()
</script>

But, as the date will presumably be read by a machine, you can use +
before new Date() to get a more machine-friendly form.

Remember, if your clientele span more than one offset from GMT, to think
carefully about whether client's date, server date, or standard date
should be used. Often, absolute time is better.

Read the current Risks Digest 24.70 9/10 (news:comp.risks) and see the
folly of using date-and-time at all when a simple absolute scale of
seconds (converted for display if needed) is appropriate. It seem that
Raptors turn by 180 degrees - I don't know about what axis - on crossing
the Date Line.
[*] But of browser-dependent form.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jun 20 '07 #6
Dr J R Stockton said the following on 6/20/2007 4:34 PM:
In comp.lang.javascript message <46***********************@unlimited.new
shosting.com>, Wed, 20 Jun 2007 05:05:14, me@?.?.invalid posted:
>Sorry, I'm still learning newsgroups. Okay, the text follows. I'm just trying
to get a date/time as a field in the submitted form.

Only really silly people use the 12-hour clock in internal data
processing. The generic adjective for them is "Americans".
I see your ugly bias has surfaced again. It displays your ignorance, not
your intelligence John.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 21 '07 #7
In comp.lang.javascript message <ob********************@telcove.net>,
Thu, 21 Jun 2007 00:31:36, Randy Webb <Hi************@aol.composted:
>
I see your ugly bias has surfaced again. It displays your ignorance,
not your intelligence John.
Stop whining and get on with the work which you promised to do, the
maintenance of the newsgroup FAQ. It's now over ninety days since the
date of FAQ - 9.70 - 2007-03-22, and since then many suggestions have
been made in response to the daily postings-for-comment.

--
(c) John Stockton, Surrey, UK. ??*@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.
Jun 21 '07 #8
Dr J R Stockton said the following on 6/21/2007 3:38 PM:
In comp.lang.javascript message <ob********************@telcove.net>,
Thu, 21 Jun 2007 00:31:36, Randy Webb <Hi************@aol.composted:
>I see your ugly bias has surfaced again. It displays your ignorance,
not your intelligence John.

Stop whining
The only one whining is you. If the truth hurts, bear the pain and move
on as it changes nothing about your ignorant bias.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 22 '07 #9

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

Similar topics

10
2037
by: Piotr Wolski | last post by:
hello, as always i have a problem:-) i'm using HTML form. User is adding some date to this form and after that i'm generating plot. When plot is generated i can see en empty form and a plot. I...
6
2313
by: deko | last post by:
I have a basic Feedback form - I want to prevent blank entries. The problem with the below code is that the form still Posts if the 'message' field is blank. The form will not post if the...
8
9425
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
4
9441
by: James Bond 007 | last post by:
I am a novice to Javascript (can do simple text-based pop-ups, but not familiar with variable manipulation). I would like to have a Javascript that gives me the start time (I don't care about...
0
1141
by: BrianDH | last post by:
Hi I hate to ask this 'cause I know there must be a simple answer but I can't find it. Vb.net Windows form
3
6403
by: fong.yang | last post by:
I have a textbox on my form label date/time. I also added a date/time column to my table as well. The table already contains records before the date/time column was added. How do I setup a...
4
2770
by: Kun | last post by:
i have a form which takes in inputs for a mysql query. one of the inputs is 'date'. normally, a user has to manually enter a date, but i am wondering if there is a way to create a button which...
3
3274
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
0
3335
by: brianrpsgt1 | last post by:
I am attempting to insert data from a HTML form using a .psp script. I can not find how to link the data that is inserted into the form to the variables in the .psp script to then insert into the...
0
7076
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
7323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6984
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
7453
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...
0
5576
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5005
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1507
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.