473,765 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Date/Time to an HTML form? - Request_Informa tion_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_g mail_dot_com)
Jun 20 '07 #1
8 35985
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><ti tle>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.get Hours();

if (currentHour >= 12)

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

else if (currentHour == 0)

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

else

{ AMPM = "AM"; }

currentMinute = DateAndTime.get Minutes();

currentSeconds = DateAndTime.get Seconds();

if (currentSeconds < 10)

{ currentSeconds = "0" + currentSeconds; }

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

return dateAndTime; }

function getCurrentDate( ) {

currentMonth = DateAndTime.get Month();

currentDay = DateAndTime.get Day();

currentYear = DateAndTime.get FullYear();

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.c om">

<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"><b r />

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

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

<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="getCurre ntTime()">
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.javas cript message <v78h735l6bi5am 6cr7sfssp749vlj hk20t@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.c om/faq/index.html>.
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jun 20 '07 #5
In comp.lang.javas cript message <46************ ***********@unl imited.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.getEle mentById("dateT ime").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.risk s) 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.demo n.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.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.javas cript message <46************ ***********@unl imited.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.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 21 '07 #7
In comp.lang.javas cript message <ob************ ********@telcov e.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.demo n.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demo n.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.javas cript message <ob************ ********@telcov e.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.javas cript 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
2063
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 want to see filled in form and a plot. don't know why i'm loosing all the data. when user adds data to the form i'm doing something like that:
6
2332
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 'email_address' field is blank, however. Why doesn't it catch empty 'message' field? <form method="POST" action= "<? $message = $_POST; $email_address = $_POST; if ( empty($message) || empty($email_address) )
8
9445
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 $ Last-Modified: $Date: 2003/10/28 19:48:44 $ Author: A.M. Kuchling <amk@amk.ca> Status: Draft Type: Standards Track
4
9546
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 the date) when the user entered my webpage and then the time that the user hit the "Submit" button on my HTML form.
0
1151
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
6417
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 date/time stamp to that textbox or column for any changes that is made to any records? I've added =Now() on the AfterUpdate properties of the text box, but it is only adding a stamp if new records are added not when there are just changes made. ...
4
2792
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 would automatically insert today's date in the date form field if the user chooses to use today's date.
3
3313
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 the field should only be showing one or the other (date or time). Even on the back end of the database where the column properties are, I have chosen the smallest date/time formats. When the aspx page runs, it shows the date and time (ie:in a...
0
3354
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 MySQL Insert statement. I am familiar with PHP, where you would write $_POST(), however I can not find the equivalent in PSP. I believe that this is the my missing piece. Technically, what is occurring that that when I click the 'Submit'...
0
9566
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9393
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9946
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8830
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7371
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5413
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3530
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2800
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.