Forum Moderators: open
I want it to be a hidden field.
Can you help?
Thanks so much
1. Use JavaScript to populate the hidden field with the user's current system date. Problems include: if the user has JavaScript turned off you won't get anything, if the user's system is set to the wrong date you'll get the wrong date.
2. Just look at the date the email was sent!
So another option is script it in during the submission process...
Javascript (on the client side)
or ASP, PHP, JSP, whatever (on the server side)
What kind of host are you on and what technologies are supported?
SuperNĪvaCain
I'm not familiar with formmail. It looks like a remotely hosted service, or a prepackaged mailer that you can just "plug'n'play" onto a website (black box).
My best guess is
javascript is your best option.
It can put a date/time stamp into your hidden form field, right at the moment the "submit" button is clicked. At risk of a client not having javascript enabled, the worst that can happen is you get no date/time stamp.
Using ASP, PHP, etc... you can fill the hidden field when the page is created, but if the page is kept open for a couple of hours before the "submit" button is clicked, then, well... your time stamp will be off by that amount too.
Getting more creative, you could have your page submit to an intermediate page, that would in turn, add it's own information and then submit onto your formmail...
SuperNĪvaCain
<html><head><title>Get submitted date</title></head>
<body>
<form method="post" onSubmit="return false;">
<input type="hidden" name="submitted_date" value="">
<!-- rest of your form -->
<input type="submit" onClick="addDate(this.form);" value="Submit">
</form>
<script type="text/javascript">
function addDate(form) {
var day = new Date();
// following all on one line
//Months is zero-based (Jan=0, Feb=1.etc.) So must be incremented
var submitted = (day.getMonth()+1)+'/'+day.getDay()+'/'+day.getYear()+' '+day.getHours()+':'+day.getMinutes()+':'+day.getSeconds();
// End all on one line
form.submitted_date.value=submitted;
//uncomment the below to get an alert showing you it indeed works
//alert(form.submitted_date.value);
form.submit();
}
</script>
</body>
</html>
Look for "submitted_date" in your server-side output. If Javascript is disabled, you won't get a submitted date but the form will still work; that's what the onSubmit=return false does.
<form method="post" onSubmit="return false;">
<input type="text" name="submitted_date" value="">
<!-- rest of your form -->
<input type="submit" onClick="addDate(this.form);" value="Submit">
</form>
<script type="text/javascript">
function addDate(form) {
var day = new Date();
// following all on one line
//Months is zero-based (Jan=0, Feb=1.etc.) So must be incremented
var submitted = (+day.getHours()+':'+day.getMinutes());
// End all on one line
form.submitted_date.value=submitted;
//uncomment the below to get an alert showing you it indeed works
//alert(form.submitted_date.value);
//form.submit();
}
</script>
</body>
</html>
THANKS!