#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0

    Count clicks on a button


    Hi,

    Very new to ASP script, however I managed to do a script which counts the number of times a web page is accessed in a database, but in fact i wanted to count the number of times a button within the same page is clicked (count number of document downloaded).
    Code:
    <% ' simply return the username and domain from the server var Dim sluDomainUser : sluDomainUser = Trim(Request.ServerVariables("LOGON_USER")) Dim sluUserIDSlash : sluUserIDSlash = InStr(sluDomainUser,"\") 'Strip off domain and this becomes User ID sluUserName = LCase(Mid(sluDomainUser, sluUserIDSlash+1)) 'Remove domain sluDomain = UCase(Left(sluDomainUser, sluUserIDSlash-1)) ' ok lets create a session record sql = "INSERT INTO tblOfferDown (ulUserid, ulDateTime) VALUES ('" & sluUserName & " ', #" & Now() & "#)" If dbQuery(rs, sql)=False Then ' we have been unable to record user id Response.Write("Error") Response.End() End If ' End the session Call EndRoutine() %>
    Any help is appreciated

    Cheers
    Last edited by vitordf; March 15th, 2013 at 08:10 AM. Reason: re title
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,429
    Rep Power
    4539
    In the asp server code that processes the button click create a counter variable in code, in session, or in your database and increment that counter each time the button is clicked.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0
    Cheers Doug any idea how would I do that as I am not sure how.

    Thanks
  6. #4
  7. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,429
    Rep Power
    4539
    Try google for some asp hit counter codes, and look a couple over. There are different ways to do what you want depending on the overall requirements. Using a database for storage of the counter is probably the most bullet-proof way to go.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo