Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submitting Time & Date in a Form...?

Status
Not open for further replies.

wuzzle

Programmer
Dec 20, 2000
75
CA
Just wondering if any of you know how to set up a form so that it knows the time and date the user submitted it at, and sends that information along with the email?

Thanks alot!
 
I just got this message from a former teacher. But I don't know how to go about this. My form is controlled by javascript, it's just the "date stamp" that I don't understand how to do. Help, anyone?

"Yep, control the form submission via javascript and use javascript to send a date stamp with the form using the Date() object."
 
When the form is submitted, you could store the current date and time in a hidden field on the form using javascript. To put it simply, say you have a form form1 with a hidden field hidden1. When the user clicks submit, your could use javascript to set the value of the field before processing the form.

document.form1.hidden1.value=new Date()

Greg.

 
Thanks for your reply! I got it working just by doing this:

document.faqform.date.value=this.day+ ", " +this.month+ " " +this.days+ ", " +this.years;

and that displays the date, but I also have to display the time in the same way. I have the code for the time written out, but what string would tell it to appear in my input field? I tried something similar to the above line but it didn't work. Here is my time code.

function writeTime() {
var today = new Date();
var hours = today.getHours();
var minutes = today.getMinutes();
var seconds = today.getSeconds();

minutes = fixTime(minutes);
seconds = fixTime(seconds);

var the_time = hours + ":" + minutes + ":" + seconds;
window.document.the_form.the_text.value = the_time;
the_timeout= setTimeout('writeTime();', 500);

}

and this is what I tried but didn't work:

document.faqform.time.value = the_time;

??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top