|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have an html form and one of the fields is the current date. Is there any way to insert the current date automatically whenever the form is submitted? I am using a cgi mail_to script. Do I have to do this with javascript? Here is my code for the date field.
<P align=left><B>Date: </B> <INPUT name=rcf_date type=hidden> </P> Thanks!! ![]() |
|
#2
|
||||
|
||||
|
Using ASP you can use the Date() function
Code:
<P align=left><B>Date: </B> <INPUT name=rcf_date type=hidden value="<%=Date()%>"> </P> |
|
#3
|
|||
|
|||
|
Thanks... but..
But I have already tried asp, I kept running into errors and I just gave up on it now. There is any way to do this without asp?
Quote:
|
|
#4
|
||||
|
||||
|
Quote:
So what you are saying is because you ran into errors, you just gave up on trying to use ASP, instead of trying to resolve the errors? There isn't a way to grab the date with HTML. The code above works. If you save it into an asp page and run it in your browser, click "View", "Source" you will see that the date gets populated into the hidden field. |
|
#5
|
||||
|
||||
|
Quote:
Code:
<script language="javascript">
window.onload=function ()
{
var now=new Date();
document.forms[document.forms.length-1].rcf_date.value = now.toGMTString();
}
</script>
<form>
<input type=text name="rcf_date">
</form>
the abouve will put full date string, to see available methods of the Date object, look here: http://www.devguru.com/Technologies/ecmascript/quickref/date.html |
|
#6
|
|||
|
|||
|
Errors running asp date(). Why would it error out?
|
|
#7
|
||||
|
||||
|
try my code - it's not using ASP... what error exactly do you get? please be more specific if you want any help.
|
|
#8
|
|||
|
|||
|
Which code?
Which code are you talking about? the html form or the asp page I have? I didn't get any error using the html form, but I just can't figure out a way to make it so it would insert the date whenever the form is submitted.
Quote:
|
|
#9
|
||||
|
||||
|
the code here:
http://forums.aspfree.com/showpost.php?p=113730&postcount=5 right after the word "Code:" |
|
#10
|
|||
|
|||
|
I know this post is 5 years old... but thanks for it still being here. I really needed to get an automated time into my form.. and this did the trick. Super..... just get rid of the toGMT and it displays the time of the user... not the gmt time... Since the form is for local use that is great.
this is what I put into my form (it is an e-mail form...so I get all the info from it in an e-mail. I changed the text to hidden so that the user does not see or change and it come through to the e-mail. Code:
<script language="javascript">
window.onload=function ()
{
var now=new Date();
document.forms[document.forms.length-1].rcf_date.value = now;
}
</script>
<form>
<input type="hidden" name="rcf_date">
</form>
URL of form: http://coldspringtx.net/Classifieds/application_form.html info that comes in the e-mail Code:
Date submitted Mon Oct 26 2009 23:27:32 GMT-0500 (Central Daylight Time) Your First and Last Name Partner First and Last Name Present Address All Phone numbers Landlord/Mortgage Information Landlord_Mortgage Co Name Address and Phone Emploment Information You Employed by Partner Employed by Your Employers Name Partners Employers Name Your Employers Phone Partners Employers Phone Your Years with company Partners Years with company Your Salery per month Partners Salery per month Misc. Information Number of children under 26 yr living with you How did you hear about rental ---- Sent from: 65.163.124.173 |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > HTML Form insert date |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|