Link to home
Create AccountLog in
Avatar of dory550 lambert
dory550 lambertFlag for United States of America

asked on

Monitoring clicks on HTML links

Hi Guys
Deployment: Website on 2003 server
language classic-ASP/VBS
IIS 6.00

I have the link below to provide customers with price catalog on website
<A href = "misc/Price_Catalog.pdf">Click here to download a price catalog</A>

I have an email code snippet which sends me email confirmations etc
Is there a way to run the a code snippet only when the link above is clicked?
Thank u
Dory
 
Avatar of scrathcyboy
scrathcyboy
Flag of United States of America image

sure, just change the link to that below in the code snippet.  The onClick="countClick():" part can count the clicks, or initiate an email giving you the email per click.  You would put a small form around the link ,and in the javascript function countClick(), you would, at the end of it use --

document.form1.submit();

form1 is the name of the form, and it submits to a server script whatever you want to be emailed to you.
<A href = "misc/Price_Catalog.pdf" onClick="countClick();>Click here to download a price catalog</A>

Open in new window

Avatar of dory550 lambert

ASKER

scratchyboy
Thanks fo your response
I am not sure How to make your solution work for me.
I need to get an email with customer number sent to me
I have in place a vbs/asp sub that does just that each time that web page is visited
But not all visits result in a catalog being downloaded
hence my request for assistance.
Dory
Avatar of golfDoctor
golfDoctor

You would use onclick event in link, and AJAX.  Do you know how to use ajax?
http://skeymedia.com/classic-asp-and-ajax-tutorial/ 
"I have in place a vbs/asp sub that does just that each time that web page is visited"

Why not have the ASP/VBS script do that when the link is clicked, not when the page is viewed.  It makes more sense to do it when the person is interested, not merely curious.  Can you not do that?
Scratchyboy
Maybe I am doing something wrong
VBScript is the default language of my ASP pages
Both codes below did not work
Click here to download a price catalog
Click here to download a price catalog
How do I connect the onclick event to the sub?
Dory
ASKER CERTIFIED SOLUTION
Avatar of scrathcyboy
scrathcyboy
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Did you see my post?  It is the appropriate way to do this.
Hi Guys
I manage to come with a simpler solution
I changed the link to read as follows:
Click here to download a price catalog

Below is the complete code for cat3.asp

<% @ LANGUAGE="vbscript" %>
<%
email1
response.redirect "misc/catalog.pdf"
Sub email1
set objmail=CreateObject("CDO.Message")
objmail.from="catalogs@mywebsite.com"
objmail.to= "catalogs@mywebsite.com"
objmail.Subject="Catalog DownLoad -- " & session("CustNumber")
objmail.HtmlBody= "Catalog dated 07/01/2008 was downloaded"
objmail.send
set objmail= Nothing
End Sub
respnonse.end
%>


golfdoctor
Tthanks for your intro to AJAX url

scrathcyboy:
Thank you very much for the time and effort you invested in helping me
I would gladly award you the points
But to do that I will have to click on "Accept as Solution"  under your solution
I am not sure if that would be acceptable here........
Dory
I thought you were looking for something a little more robust, and not just for a single file redirect.  Accept which ever one helped you, if either.
Scratchyboy
I decded to go with one of your solutions
Thank you
Dory