Browser-side current date and time!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to have the current date and time prepopulate one of the text boxes in my FP project. Im using ASP. When I place

<%=Now()%>

in the "initial values" box of the "text box properties" for the field of interest, it runs great but it gives the time *at the server*. Unfortunately, the server is in a different time zone! Is there a waythat I capture the current date and time at the browser??

Thanks!
 
If your text box is

<input type="text" name="txtDate" size="50">

then add

function initForm(){
curdate = new Date();
if (document.forms[0].txtDate.value == ""){
document.forms[0].txtDate.value = curdate;
}
}
</script>

to your <head> section and

onload="initForm();"

to the <body> tag.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
|| Microsoft FrontPage Version 2002 Inside Out
|| Web Database Development Step by Step .NET Edition
|| Troubleshooting Microsoft FrontPage 2002
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------



-----Original Message-----
I am trying to have the current date and time
prepopulate one of the text boxes in my FP project. Im
using ASP. When I place
<%=Now()%>

in the "initial values" box of the "text box properties"
for the field of interest, it runs great but it gives the
time *at the server*. Unfortunately, the server is in a
different time zone! Is there a waythat I capture the
current date and time at the browser??
 
Back
Top