Jump to content

date as default value


Loriot

Recommended Posts

Hi all,I need some help with that. I am trying to get the date & time as a default value into a form.I tried a lot of variations with and without header functions like for example

<input type="text" name="Time" value="?[$document.write(Date())]" />

How do I get this?? :) Thanx for any help you can give.\Loriot

Link to comment
Share on other sites

<html><body><script type="text/javascript">var d = new Date()var hours = d.getHours()var minutes = d.getMinutes()if (minutes<=9){document.write("<form>")document.write("<input type='text' name='time' value=hours + ':0' + minutes>")}else{document.write("<form>")document.write("<input type='text' name='time' value=(hours + ':' + minutes)>")}</script></form></body></html>

It isn't working so well, shows "Hours" in the text-field. :)

Link to comment
Share on other sites

do this

<html><body><script type="text/javascript">var d = new Date()var hours = d.getHours()var minutes = d.getMinutes()document.write('<form>')if (minutes<=9)	document.write('<input type="text" name="time" value="' + hours + ':0' + minutes + '">')else	document.write('<input type="text" name="time" value="' + hours + ':' + minutes + '">')document.write('</form>')</script></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...