I set up an Access database with a text field to record the website name and a date field to record the date/time of the access. I have set up a page with various anchors set up to call up different websites. When the user clicks a particular anchor, I want to be able to record this information to the database. Is there an event which can be connected to the anchor and update the database?
How to Record hits to website
Collapse
X
-
That depends.
Is the web page built in .asp or asp.net (.aspx)?
You would need to use an onclick event but the problem is that unless the site is built in asp.net the onclick event can only be captured in javascript on a regular HTML or .asp page.
The other option is if it is classic asp (.asp) you can instead have the link point to one of your own pages (say Process.asp) that is a redirect handler, and write out the counts before directing them.
So if you set up a series of links and assign them an code each of your links would start to look like this:
Process.asp?lin kid=01
Process.asp?lin kid=02
Then on the process page just do this
If you are in fact using asp.net for your pages you could do this a different way by using the asp.net link controls, and use the onclick event to capture the users click, rather then redirecting them.Code:'Process.asp dim MyLinkCode MyLinkCode = request.querystring("linkid") Select Case MyLinkCode Case "01" 'CNN.com sql = "insert into MyTable (name,date) VALUES ('cnn.com',Date)" dbconn.execute sql 'then you actually send them to the page response.redirect("http://www.cnn.com") Case "02" 'bytes.com sql = "insert into MyTable (name,date) VALUES ('bytes.com',Date)" dbconn.execute sql 'then you actually send them to the page response.redirect("http://www.bytes.com") End Select
Comment