473,385 Members | 2,069 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,385 software developers and data experts.

Time stamp on HTML form submittal

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.

For example, my current HTML form e-mails
the following to me when the user hits "Submit"
(these are just sample lines):

NAME = James Bond
CITY = New York

Obviously, the user entered the above values
in a text widget that was on my webpage.

I'd like to add to the above something like the following,
but without the user having to do anything other
than hit the "Submit" button:

START_TIME = 12:05pm
END_TIME = 12:10pm

The "START_TIME" would be the time that the user
first entered my webpage, while the "END_TIME"
would be the time that the user hit the "Submit" button
on that same webpage (I can't rely on the e-mail timestamp
for the "END_TIME", because there may be internet delays
which would screw up my results).

If you supply a script, you needn't give too much detail/comments
(I'm a computer programmer with over 25 years of experience,
but only 5+ years as a novice HTML programmer),
as long as you show all the necessary code lines.
If 24-hour time would be easier, then that's fine, too.

Any help would be greatly appreciated.

Thanks!


-----
Bond . . . James Bond
Do not reply via e-mail.
The address is phony to prevent spam, etc.
Thank you for understanding.
Jul 23 '05 #1
4 9420
James Bond 007 wrote:

For example, my current HTML form e-mails
the following to me when the user hits "Submit"
(these are just sample lines):

NAME = James Bond
CITY = New York

Obviously, the user entered the above values
in a text widget that was on my webpage.

I'd like to add to the above something like the following,
but without the user having to do anything other
than hit the "Submit" button:

START_TIME = 12:05pm
END_TIME = 12:10pm

<body
onload="document.forms[0].elements['START_TIME'].value = new Date()">
<form...
onsubmit="this.elements['END_TIME'].value= new Date()">
<input name="START_TIME" type="hidden">
<input name="END_TIME" type="hidden">

....

</form>
Mick
Jul 23 '05 #2
The result from your script gives the date AND time,
but that's fine; I can always parse out the non-time parts.

Thanks very much! : )
On Tue, 09 Nov 2004 22:04:18 GMT, Mick White
<mw******@rochester.rr.com> wrote:
James Bond 007 wrote:

For example, my current HTML form e-mails
the following to me when the user hits "Submit"
(these are just sample lines):

NAME = James Bond
CITY = New York

Obviously, the user entered the above values
in a text widget that was on my webpage.

I'd like to add to the above something like the following,
but without the user having to do anything other
than hit the "Submit" button:

START_TIME = 12:05pm
END_TIME = 12:10pm

<body
onload="document.forms[0].elements['START_TIME'].value = new Date()">
<form...
onsubmit="this.elements['END_TIME'].value= new Date()">
<input name="START_TIME" type="hidden">
<input name="END_TIME" type="hidden">

...

</form>
Mick



-----
Bond . . . James Bond
Do not reply via e-mail.
The address is phony to prevent spam, etc.
Thank you for understanding.
Jul 23 '05 #3
JRS: In article <41*************@netnews.att.net>, dated Thu, 11 Nov
2004 08:24:41, seen in news:comp.lang.javascript, James Bond 007
<Do**********@here.com> posted :
The result from your script gives the date AND time,
but that's fine; I can always parse out the non-time parts.


Responses should go after trimmed quotes : see newsgroup FAQ.

If all relevant browsers give, as would be sensible, 24-hour time, then
replacing new Date() with String(new Date()).match(/\d\d:\d\d:\d\d/)
will do it - at least in my browser; it has just given 19:25:50 .

--
© 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
(follow-up)

Here's how I re-arranged the script so that I would receive
only the start and end TIMES:

----------------
<HTML>

<HEAD></HEAD>

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!-- hide from non-Java browsers

window.onload=function () {
var now=new Date(); // set the full date

// extract the START time for the user's time zone
document.forms[document.forms.length-1].START_TIME.value =
now.toLocaleTimeString();
}

// this is called when the user hits the "Submit" button
function ValidateTheForm() {
(do some validation stuff here)

var now=new Date(); // set the full date

// extract the END time for the user's time zone
document.forms[document.forms.length-1].END_TIME.value =
now.toLocaleTimeString();
}

// end hiding

</SCRIPT>

(etc)

<FORM NAME="NTRPTEST" METHOD="POST" ACTION="(CGI script)"
onSubmit="return ValidateTheForm()">

<INPUT TYPE="hidden" NAME="to" VALUE="(something)">
<INPUT TYPE="hidden" name="subject" VALUE="(something)">
<INPUT TYPE="hidden" NAME="form" VALUE="(something)">
<INPUT TYPE="hidden" NAME="admin" VALUE="(something else)">
(etc)
<!-- retrieve START & END times from Javascript, above,
-- and put result into submitted form without user knowing about it
-->
<INPUT TYPE="hidden" NAME="START_TIME">
<INPUT TYPE="hidden" NAME="END_TIME">
(etc)

<INPUT TYPE="submit" NAME="Submit" VALUE="SUBMIT">
(etc)
</FORM>

(etc)

</BODY>
</HTML>

----------
Here is an actual result that I got via e-mail
after the user hit the "Submit" button
(the user knows nothing about the times;
i.e., the user didn't have to touch or enter any values,
as far as that is concerned):

START_TIME = 10:04:39 AM
END_TIME = 10:21:31 AM

I will use these values to determine how long it takes
the user to fill-out the form; in this case, about 17 minutes!
(I probably could have done the calculation in the HTML,
but I want to know *when* they looked at the form, too!).

================================================== ======================
James Bond 007 wrote:
The result from your script gives the date AND time,
but that's fine; I can always parse out the non-time parts.

Thanks very much! : )
On Tue, 09 Nov 2004 22:04:18 GMT, Mick White
<mw******@rochester.rr.com> wrote:

<body
onload="document.forms[0].elements['START_TIME'].value = new Date()">
<form...
onsubmit="this.elements['END_TIME'].value= new Date()">
<input name="START_TIME" type="hidden">
<input name="END_TIME" type="hidden">

...

</form>
Mick


James Bond 007 wrote:

For example, my current HTML form e-mails
the following to me when the user hits "Submit"
(these are just sample lines):

NAME = James Bond
CITY = New York

Obviously, the user entered the above values
in a text widget that was on my webpage.

I'd like to add to the above something like the following,
but without the user having to do anything other
than hit the "Submit" button:

START_TIME = 12:05pm
END_TIME = 12:10pm



-----
Bond . . . James Bond
Do not reply via e-mail.
The address is phony to prevent spam, etc.
Thank you for understanding.
Jul 23 '05 #5

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

Similar topics

1
by: John Floria | last post by:
Hello, I have several links on my page that run reports. Each link submits a seperate form. The onclick event of the link opens a new named window where I control the "chrome". The form's...
7
by: Don | last post by:
Hi all, With regards to the following, how do I append the datetimestamp to the filenames in the form? The files are processed using the PHP script that follows below. Thanks in advance,...
3
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...
3
by: phried1 | last post by:
I have created a form and inserted the following tables: Date Entered Time Entered Date Modified Time Modified Essentially how and where can I have these dates and times recorded so when the...
2
by: kewi | last post by:
Hi, Does anybody knows how to create a time stamp in HTML on an online form and how can I send this online form to myself and another email filled in by a third person? Thank you for your help.
4
by: SilentThunderer | last post by:
Hey folks, Let me start out by letting you know what I'm working with. I'm building an application in VB 2005 that is basically a userform that employees can use to "Clock in". The form...
1
by: 6afraidbecause789 | last post by:
Hi - I am using a Date/Time Picker popup form for users to choose a a date and time for use on a separate entry form. The date/time on the entry form is actually entered automatically as a...
0
by: Edwin.Madari | last post by:
os.paht.gmtime(path) returns the last modification of path. check out http://docs.python.org/lib/module-os.path.html regards Edwin -----Original Message----- From:...
1
by: raziofer | last post by:
I have a form where fileds are representing status (Yes/No data type). For each field, a time stamp is required when status was changed to Yes. These updates are performed in a subform. Can anybody...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.