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

capture time spent for filling form 1

Status
Not open for further replies.

indupriya9

Programmer
Joined
Oct 29, 2002
Messages
99
Location
NZ
Hi there

I would like to capture time spent on the form and display the same on the next page on submitting the form.

The code I am using on the form is as follows:

Code:
<BODY ms_positioning="FlowLayout" onLoad="startTime = new Date(); document.form1.startTime.value=startTime.valueOf();" onUnload="endTime = new Date(); document.form1.timerField.value = endTime.valueOf() - startTime.valueOf();">
<form name="form1" method="post" action="testpage.asp">
<input type="hidden" name="timerField" >
</form>


The code I have on the testpage.asp is as follows:

Code:
dim timer
timer=Request.Form("timerField")
  Response.Write "Timer:" &timer
  Response.End

But it does not display anything on the next page.

Can anyone please let me know where I am going wrong?

Thanks in advance
ip
 
Can anyone please let me know where I am going wrong?

Well.... first off, you're posting an ASP question in the javascript forum.

Try here: forum333

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
not completely, kaht.

you could try doing something like this:

Code:
function doStart() {
    document.forms['myForm'].elements['dtStartDate'].value = new Date();
}

function doEnd() {
    document.forms['myForm'].elements['dtEndDate'].value = new Date();
}

Code:
<body onload="doStart();">

Code:
<form onsubmit="doEnd();">
  <input type="hidden" name="dtStartDate" />
  <input type="hidden" name="dtEndDate" />
</form>

And then do the date math on the server side. Keep in mind, however, that you wouldn't get any information if the user has disabled javascript...



*cLFlaVA
----------------------------
spinning-dollar-sign.gif
headbang.gif
spinning-dollar-sign.gif

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Hi clFlava

Thanks for your very prompt help. When I use the dostart and doend functions. I am getting an "Object Required" error on line 32 and the line 32 is function dostart()

What could be wrong?

Thanks
ip
 
it's because cory likes to keep you guessing, he's cool like that

Code:
<form [!]id="myForm"[/!] onsubmit="doEnd();">

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Hi everyone

I got this working. cLFlaVA, you get a star for pointing me in the right direction. But why didn't my first code work? Any ideas ???

Thanks
ip
 
I'm not sure the unLoad event happens before submitting.

Cheers,
Dian
 
Thanks for ur comments. I will try in the onsubmit event.

cLFlaVA, I have given u a star yesterday. But I don't know why it didn't go through. I will try now.

ip
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top