Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: asp Counter

  1. #1
    mex
    mex is offline
    Regular Coder
    Join Date
    Jul 2003
    Location
    somewhere
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    asp Counter

    This is counter written in asp and works fine ..... I would like this page to work in .html page and not in .asp

    Is there any possibility to modify the script so that it works in a .html page. Say javascipts....

    <%
    Dim CounterFile
    CounterFile = "counter.mdb"
    Dim CookieSwitch
    CookieSwitch = "on"
    Dim CounterDataConn
    Dim CounterSQL
    Dim CounterRs
    Dim CounterHits

    Id = Clng(CounterId)

    Set CounterDataConn = Server.CreateObject("ADODB.Connection")
    CounterDataConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath(CounterFile)
    CounterSQL = "SELECT * FROM Counter WHERE Id=" & Id
    Set CounterRs = CounterDataConn.Execute(CounterSQL)
    If CounterRs.EOF then
    CounterSQL = "INSERT INTO Counter(Id,Count) Values(" & Id & ",1)"
    Set CounterRs = CounterDataConn.Execute(CounterSQL)
    CounterHits = 1
    Else
    If CounterAction = "GetStatus" then
    CounterHits = Clng(CounterRs("Count"))
    Else
    If NOT Request.Cookies("CounterHits") = "" and Id = 1 then
    CounterHits = Request.Cookies("CounterHits")
    Else
    CounterHits = Clng(CounterRs("Count"))
    CounterHits = CounterHits + 1
    CounterSQL = "UPDATE counter SET count = " & CounterHits & " where id = " & id
    CounterRs = CounterDataConn.Execute(CounterSQl)
    Response.Cookies("CounterHits") = CounterHits
    End If
    End If
    End If

    Set CounterRs = nothing
    CounterDataConn.Close
    Set CounterDataConn = nothing

    Response.Write CounterHits
    Wonder

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Normally NO. Javascript can't read files or databases unless with ActiveX and IE in which it's unusual and inadvisable especially in the internet zone.

    BTW, why can't you use that script?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •