...

View Full Version : asp Counter



mex
02-03-2004, 11:41 AM
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

glenngv
02-03-2004, 11:46 AM
Normally NO. Javascript can't read files or databases unless with ActiveX and IE (http://www.codingforums.com/showthread.php?s=&threadid=31730) in which it's unusual and inadvisable especially in the internet zone.

BTW, why can't you use that script?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum