473,385 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ASP Help Please!

I have a script. Its a login form that has the user enter their First Name,
Last Name and ID #. That data along with the currdate and currtime is
placed in an access database and the framed page loads. I would like to be
able to record in the database number of minutes spent on the page when they
exit the page. Any help will be greatly appreciated.

Thanks all.

Rich
Jul 19 '05 #1
3 2388
Some other ways besides Ray's session variables:

1) add a "LAST_ACCESS_TIME" column to the table. Each time the user views a
page, update the record with the current time. This way you will know the
start time of the users session, and the time that any page was last
accessed. (Subtract end from start and you get session length). This method
means a database hit on every page, so if you have high traffic on this
site, you may want to reconsider using access and use another database
server (SQL Server, Oracle, Postgres, etc).

2) Have a Javascript onpage.unload or window_onbeforeunload function that
changes the document location to a logoutpage. The logout page could update
the database with the session end time. Of course, you would need this on
each page, and you'd want to check where the user was going before hand so
you could then redirect them to the right place. I don't think this would
work if the user closes the window though. So, althought probably feasible,
this method would be a pain in the butt to get right. (Especially if you
want cross browser capability).

Lastly, if you are expecting to run the website in a server pool, the
Session object doesn't (easily) exist across multiple servers (.NET helps
this though).

Steve
"No Spam Please" <RJ*******@aol.com> wrote in message
news:0B*********************@news4.srv.hcvlny.cv.n et...
I have a script. Its a login form that has the user enter their First Name, Last Name and ID #. That data along with the currdate and currtime is
placed in an access database and the framed page loads. I would like to be able to record in the database number of minutes spent on the page when they exit the page. Any help will be greatly appreciated.

Thanks all.

Rich

Jul 19 '05 #2
Let me explain more on what I am doing.

The login form takes the user to a webcast framed template. From that
template they have 9 videos listed. All videos are manditory viewing and we
need to verify that they had the page open (video is embedded on the page)
based on number of minutes on the page. I would like to track how much time
is spent on each video.

Structure looks like this:

Login.asp goes to:

clip1/wm_player_frameset.asp
from here the user can select 8 other videos which goes to

clip2/wm_player_frameset.asp
clip3/wm_player_frameset.asp
clip4/wm_player_frameset.asp
clip5/wm_player_frameset.asp
clip6/wm_player_frameset.asp
clip7/wm_player_frameset.asp
clip8/wm_player_frameset.asp
clip9/wm_player_frameset.asp

The database has fields called:

firstn
lastn
VZID
currDate
currTime
clip1
clip2
clip3
clip4
clip5
clip6
clip7
clip8
clip9

I would like to populate those fields (clip#) with the number of minutes
spent at each wm_player_frameset.asp page
I know I have to also pass at least the ID field value between pages.
I was able to find a script that assigns the number of minutes on the page
to a varable (see below). I can call that varable clip1, clip2, clip3... in
each wm_player_frameset.asp file but I don't know how to have the OnUnload
write the varable to the database.

<SCRIPT LANGUAGE="Javascript">

pageOpen = new Date();
function timeon() {
pageClose = new Date();
minutes = (pageClose.getMinutes() - pageOpen.getMinutes());
{
clip1 = (minutes);
}
}
// End -->
</SCRIPT>
</HEAD>

<BODY OnUnload="timeon()">

Thanks
Rich
Jul 19 '05 #3
The problem you are going to have is knowing when the user exits the browser
or leaves the page that each video is on. When the user leaves the page, you
could redirect somewhere else to do that database recording, but when they
close the browser, this isn't possible. (I don't think) Since the window
onunload scripts are all client side also, the cannot hit the database
(unless you start putting direct client access to the database on the site,
which is something you probably don't want. ) So you have 2 problems,
recording the data you want to capture, and storing the data into the
database.

You could record the data in user cookies. So you could have a client side
javascript block like: (this is freehand coded.. probably has syntax errors
and such:

<SCRIPT>

var video_number = 1;
window.onload = function(e)
{
var now = new Date()
createCookie("Load" + video_number,now.GetTime(),365);
}

window.onunload = function(e)
{
var now = new Date()
createCookie("Unload" + video_number,now.GetTime(),365);
}

function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
</SCRIPT>

This coded will save the data.

When the next video loads, you could then check all the user's cookies to
audit them:

<%

For x = 1 to Request.Cookies.Count
if instr(Request.Cookies.Key(x),"Load") > 0 then
videoNum = cLng(replace(request.cookies.Ken(x),"Load","")
unloadTime = cDate(request.Cookies(request.cookies.key(x))
' Store this in database
else if
instr(Request.Cookies.Key(x),"Unload") > 0 then
videoNum = cLng(replace(request.cookies.Ken(x),"Unload","")
loadTime = cDate(request.Cookies(request.cookies.key(x))
' Store this in database
end if
end if
next
%>

You could also force users to an audit page that will record all the cookies
to the database and then let them know if they "passed" or not.

Hope this helps, it's early in the morning, so I'm sure my code needs a lot
of work, but I hope you get the idea.

Steve

"No Spam Please" <RJ*******@aol.com> wrote in message
news:gj*********************@news4.srv.hcvlny.cv.n et...
Let me explain more on what I am doing.

The login form takes the user to a webcast framed template. From that
template they have 9 videos listed. All videos are manditory viewing and we need to verify that they had the page open (video is embedded on the page)
based on number of minutes on the page. I would like to track how much time is spent on each video.

Structure looks like this:

Login.asp goes to:

clip1/wm_player_frameset.asp
from here the user can select 8 other videos which goes to

clip2/wm_player_frameset.asp
clip3/wm_player_frameset.asp
clip4/wm_player_frameset.asp
clip5/wm_player_frameset.asp
clip6/wm_player_frameset.asp
clip7/wm_player_frameset.asp
clip8/wm_player_frameset.asp
clip9/wm_player_frameset.asp

The database has fields called:

firstn
lastn
VZID
currDate
currTime
clip1
clip2
clip3
clip4
clip5
clip6
clip7
clip8
clip9

I would like to populate those fields (clip#) with the number of minutes
spent at each wm_player_frameset.asp page
I know I have to also pass at least the ID field value between pages.
I was able to find a script that assigns the number of minutes on the page
to a varable (see below). I can call that varable clip1, clip2, clip3... in each wm_player_frameset.asp file but I don't know how to have the OnUnload
write the varable to the database.

<SCRIPT LANGUAGE="Javascript">

pageOpen = new Date();
function timeon() {
pageClose = new Date();
minutes = (pageClose.getMinutes() - pageOpen.getMinutes());
{
clip1 = (minutes);
}
}
// End -->
</SCRIPT>
</HEAD>

<BODY OnUnload="timeon()">

Thanks
Rich

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Numberwhun | last post by:
Hello everyone! I am trying to learn java and have run into kind of a snag. Here is the code that I have so far: ------ <begin_code> ---------- import javax.swing.*; import...
1
by: HolaGoogle | last post by:
Hi all, Please help me with the following..it's realy urgent and i tried everything i could and i can't get it work properly!! Thanks in advance. Here's what i'm trying to accomplish: in my...
0
by: s_erez | last post by:
Hi, This is a realy tricky one. I have an ASP.NET application where some pages are reading data from a DB and presenting reports. In order for the user to wait while the page is reading data from...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
4
by: pshindle | last post by:
DB2 Team - I just downloaded and unzipped the new Fixpack 9 for DB2 ESE V8 for Windows (FP9_WR21350_ESE.exe). I then burned the unzipped Fixpack files to a CD. I proceded to install this...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
4
by: fatboySudsy | last post by:
Hi, I have constructed a client program that has given me some error codes that i just cannot see. I was wondering if a different set of eyes with much more experience than me could help me out. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.