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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Putting a timestamp in a Data Access Page field

Status
Not open for further replies.

ericbrown2

Technical User
Jan 21, 2005
4
0
0
US
Hey guys, I'm new here and I have a absolute zero level of coding knowlege. I am creating a DAP database for my department at work and am trying to set up a site log that users can log technicians into. The problem is that right now you have to manually enter the time/date they arrive onsite and the time/date they leave. I found a javascript code that will stamp the current time when you click the target but I can't get the results (current date/time) to appear in the time/date field. Here's the Javascript code:

Code:
SCRIPT language=JavaScript event=onclick for=time_in>
<!-- Begin
Stamp = new Date();
year = Stamp.getYear();
if (year < 2000) year = 1900 + year;
document.write('<font size="2" face="Arial"><B>' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+ year + '</B></font><BR>');
var Hours;
var Mins;
var Time;
Hours = Stamp.getHours();
if (Hours >= 12) {
Time = " P.M.";
}
else {
Time = " A.M.";
}
if (Hours > 12) {
Hours -= 12;
}
if (Hours == 0) {
Hours = 12;
}
Mins = Stamp.getMinutes();
if (Mins < 10) {
Mins = "0" + Mins;
}	
document.write('<font size="2" face="Arial"><B>' + Hours + ":" + Mins + Time + '</B></font>');
// End-->

At this time, if you click the field "time_in", it generates the current time/date, but it places it in a new blank page. If someone could help me I'd really appreciate it. Oh yeah, if it helps I'm on XP Pro at work and running the DAP on our intranet.
 
I'm not sure why you want the current time but if you do, you could try defaulting the time to Now() in the database so when you create a new record you automatically get it timestamped.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top