ASP - Problemas con el contador

 
Vista:
sin imagen de perfil

Problemas con el contador

Publicado por Amaya (5 intervenciones) el 21/02/2007 10:19:54
Hola a todos,
Tengo un problema con un contador de la página web.
Lo que intento es que al hacer clic sobre una imagen, me sume 1 al contador que tengo en una base de datos. El problema es que me aumenta 1 el contador sin hacer clic sobre la imagen, se aumenta nada más cargar la página.
El código que tengo es el siguiente:

<%' <DOCUMENTACION INICIO>

'FUNCION :
'DESCRIPCION : Pagina de Eventos. Nafarco
'RETORNO :
'PARAMETROS IN :
'PARAMETROS OUT :

'HISTORIAL :
'REFERENCIA : 22/04/2002
'DESCRIPCION : Version Inicial

'<DOCUMENTACION FIN> %>

<%

Sub Contador()

Dim rs
Dim ssql

Set rs = CreateObject("ADODB.Recordset")
ssql = "SELECT * FROM eb_ContadorVisitas WHERE xcliente_id = " & session("usuario")

rs.CursorType = 1
rs.LockType = 2
rs.Open ssql, application("conn")


'Comprabamos si es fin de fichero

if not rs.eof then

rs.Fields("xcont_visBannerCaixaFebrero2007") = (rs.Fields("xcont_visBannerCaixaFebrero2007").value) + 1

else

'Si es fin de fichero añadimos un registro nuevo
rs.AddNew

'Insertamos campos
rs.Fields("xcliente_id") = usuario
rs.Fields("xcont_visBannerCaixaFebrero2007") = 1



end if

'Guardamos los cambios

rs.Update
rs.close
set rs = nothing


End Sub
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Nafarco</title>
<link rel="STYLESHEET" type="text/css" href="estilos/eb_Nafarestilo.css">
</head>

<body background = "images/menu-top.jpg" style="background-repeat: no-repeat" topmargin="0" leftmargin="0">
<table width="100%" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="47%" valign="top">
</td>
<td align="center" valign="top">
<table width="100%" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td height="62px" colspan="5" valign="top" align="right">  
<%
if application("bd")="0" then
ssql="SELECT (SELECT COUNT(*) FROM EB_BANNER where xfechaini <= {d'" & Year(date) & "-" & Month(date) & "-" & Day(date) & "'} and xfechafin >= {d'" & Year(date) & "-" & Month(date) & "-" & Day(date) & "'}) AS total, xbanner_id FROM eb_banner where xfechaini <= {d'" & Year(date) & "-" & Month(date) & "-" & Day(date) & "'} and xfechafin >= {d'" & Year(date) & "-" & Month(date) & "-" & Day(date) & "'}"
else
ssql="SELECT (SELECT COUNT(*) FROM EB_BANNER where xfechaini <= '" & Year(Date) & "/" & Month(date) & "/" & Day(date) & "' and xfechafin >='" & Year(Date) & "/" & Month(date) & "/" & Day(date) & "') AS total, xbanner_id FROM eb_banner where xfechaini <= '" & Year(Date) & "-" & Month(date) & "-" & Day(date) & "' and xfechafin >='" & Year(Date) & "-" & Month(date) & "-" & Day(date) & "'"
end if

set rs=application("conn").execute(ssql)
if not rs.eof then
dim dimension
dimension=rs("total")
dim Matriz(50)
rs.movefirst
i=0
do while not rs.eof
matriz(i)=rs("xbanner_id")
i=i+1
rs.movenext
loop

randomize(Timer)
azar=round(rnd()*(dimension-1))
id=Matriz(azar)
ssql="select ximagen,xenlace from eb_Banner where xbanner_id="&id
set rs2=application("conn").execute(ssql)
if not rs2.eof then%>
<a href="<%=rs2("xenlace")%>" onClick="<%Contador()%>" target="_blank"> <img src="images/<%=rs2("ximagen")%>" width="220px" height="53px" border="0"> </a>
<% end if
rs2.close
set rs2=nothing%>
<% else%>
<img src="images/banner.gif" width="414px" height="53px">
<% end if
rs.close
set rs=nothing%>
</td>
</tr>
<tr>
<td align="center" width="9%">
<A href="eb_NafarFrameEmpresa.asp" target="_top" style ="text-decoration:none" onfocus="this.blur();">
<span class="MenuCabecera" style="cursor:hand" onmouseover="this.className='MenuCabeceraOver'" onmouseout="this.className='MenuCabecera'">
Empresa
</span>
</A>
</td>
<td align="center" width="20%">
<%if session("usuario") <> "" then%>
<A href="eb_NafarFrameExtranet.asp" target="_top" style="text-decoration:none" onfocus="this.blur();">
<%else%>
<A href="eb_NafarSociosCooperadores.asp" target="contenido" style="text-decoration:none" onfocus="this.blur();">
<%end if%>
<span class="MenuCabecera" style="cursor:hand" onmouseover="this.className='MenuCabeceraOver'" onmouseout="this.className='MenuCabecera'">
Socios y Clientes
</span>
</A>
</td>

<td align="center" width="10%">
<A href="eb_NafarContactar.asp" target="contenido" style ="text-decoration:none" onfocus="this.blur();">
<span class="MenuCabecera" style="cursor:hand" onmouseover="this.className='MenuCabeceraOver'" onmouseout="this.className='MenuCabecera'">
Contacto
</span>
</A>

</td>
<td align="center" width="10%">
<A href="http://www.portalfarma.com/home.nsf" target="nuevo" class="EnMenu" style ="text-decoration:none" onfocus="this.blur();">
<span class="MenuCabecera" style="cursor:hand" onmouseover="this.className='MenuCabeceraOver'" onmouseout="this.className='MenuCabecera'">
Noticias
</span>
</A>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

Gracias por vuestra ayuda,

Un saludo
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

RE:Problemas con el contador

Publicado por neto (5 intervenciones) el 03/07/2008 18:30:26
como resolviste el problema del contador que preguntaste en
http://www.lawebdelprogramador.com/news/mostrar_new.php?id=7&texto=ASP&n1=421916&n2=0&n3=0&n4=0&n5=0&n6=0&n7=0&n8=0&n9=0&n0=0
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar