Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old May 4th, 2000, 04:02 PM
smmorrow smmorrow is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: Pennsylvania, USA
Posts: 37 smmorrow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 15 sec
Reputation Power: 9
I need the ability to place a timer on a page that will be generated from a cgi-script. I've found timer javascript routines, which I could imbed into the perl but with my limited javascript knowledge - I don't know if I'll be able to capture the time when the user leaves the page.
Basically, I need the timer to not only display, but allow me to capture the elapsed time and update a database with it.
Has anyone done something like this, or can anyone give me some advice on the best way to accomplish this?

Thanks!
Sharon

Reply With Quote
  #2  
Old May 4th, 2000, 07:14 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
You can place a timestamp of which when the perl script is executed. But you can't capture the time when your visitor leaves the page since your script doesn't get executed anymore by doing so.
However, you can capture the timestamp for the next visit of that particular visitor by using cookie. PHP does a better job than Perl in this case.

Reply With Quote
  #3  
Old May 5th, 2000, 10:05 AM
mcsimon mcsimon is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 179 mcsimon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 37 m 38 sec
Reputation Power: 9
Send a message via AIM to mcsimon Send a message via Yahoo to mcsimon
you can use the event handlers Onload and onUnload to capture the time the user loads a page and the time a user leaves the page. Afterwards, subtract the two times to find out how long the user was on the page.
You can hold this value in a hidden form element and send it via cgi to your database.

You'll need to become acquainted with the Date method in JavaScript.

Hope this helps you get closer to your solution.

Reply With Quote
  #4  
Old May 5th, 2000, 01:48 PM
smmorrow smmorrow is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: Pennsylvania, USA
Posts: 37 smmorrow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 15 sec
Reputation Power: 9
This sounds like a good solution, although I guess I would do this in addition to actually placing the javascript code there to show the representation of the incrementing time on the screen while they're visiting (a small clock window at the top of the page). My limited experience with javascript is still causing me a problem with this approach, however - how do I get the value from the calculation (difference between load and unload times) into the hidden form field in order to pass it to the cgi-script?

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by mcsimon:
you can use the event handlers Onload and onUnload to capture the time the user loads a page and the time a user leaves the page. Afterwards, subtract the two times to find out how long the user was on the page.
You can hold this value in a hidden form element and send it via cgi to your database.

You'll need to become acquainted with the Date method in JavaScript.

Hope this helps you get closer to your solution.
[/quote]


Reply With Quote
  #5  
Old May 5th, 2000, 06:59 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
>>you can use the event handlers Onload and onUnload to capture the time the user loads a page and the time a user leaves the page

You really can't with onUnload. The script doesn't get executed. Once you left the page, you no longer with it.

>>how do I get the value from the calculation
Let your cgi script do this dirty work.

>>into the hidden form field in order to pass it to the cgi-script
You have to make a form submit button with "Click here to Leave", then the hidden field can be passed to the script. If the visitor doesn't click it, the time can't be captured.
########################################
Take a look at this under "Date & Time" link.. http://www.essex1.com/people/timothy/js-index.htm

Reply With Quote
  #6  
Old May 6th, 2000, 02:10 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 9
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
<<<You have to make a form submit button with "Click here to Leave", then the hidden field can be passed to the script. >>>

I think this is the viable solution for solving smmorrow's problem.




------------------
SR -
shiju.dreamcenter.net

Reply With Quote
  #7  
Old May 8th, 2000, 07:43 AM
smmorrow smmorrow is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: Pennsylvania, USA
Posts: 37 smmorrow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 15 sec
Reputation Power: 9
I already have a button on the page that the visitor clicks to move on to the next page. I can use this to 'stop the clock' and submit the form to the cgi-script. So, combining the unLoad to start the clock and the onClick to stop it, I should have what I need to time the visitor.
I know I'm missing something due to my inexperience with javascript - but my main question remains: how do I get the value of a javascript variable into a form field for passing to a cgi-script?

smmorrow

Reply With Quote
  #8  
Old May 8th, 2000, 11:14 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
If you take a look at http://www.essex1.com/people/timothy/js-index.htm under Date & Time, you should see..

<INPUT TYPE="text" NAME="local" SIZE=16 VALUE="Current Time">

>>how do I get the value of a javascript variable into a form field for passing to a
cgi-script?
As you can see that form field name is "local" but the form is <form> instead of <form method="POST" action="/cgi-bin/script.pl">
So it's all up to your script.pl to handle the value of "local" from your 'time page' and pass it onto the next page.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Timer on perl-cgi generated page


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway