Hai ragione... non riesco mai a spiegarmi bene
Ora posto il codice per rendere più chiaro il concetto:
codice:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="jquery-latest.js" type="text/javascript"></script>
<script type="text/javascript">
function load(id,voto) {
$("#contentArea").load("voto.asp?id="+id+"&voto="+voto+"");
}
</script>
</head>
<body>
<div id="contentArea">
<% id = Request.QueryString("id")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & Server.MapPath("/mdb-database/articoli.mdb") & ";Jet OLEDB:Database"
Set RS = Server.CreateObject("ADODB.Recordset")
Sql = "select * from articoli WHERE id="& id
RS.Open Sql, Conn
Media_Voti = RS("Media_Voti")
Voti = RS("voti")
nomeSession = "votato" & id
If Session(nomeSession) <> True Then
For s = 1 to 5
If Clng(Media_Voti) > (s - 0.30) Then %>
<img onclick="javascript:load(<%=id%>,<%=s%>);" alt="<%=s%>" name="<%=s%>" src="pictures/star.jpg"> <%
ElseIf Clng(Media_Voti) <= (s - 0.30) And Clng(Media_Voti) >= (s - 0.80) Then %>
<img onclick="javascript:load(<%=id%>,<%=s%>);" alt="<%=s%>" name="<%=s%>" src="pictures/starhalf.jpg"> <%
ElseIf Clng(Media_Voti) < (s - 0.80) Then %>
<img onclick="javascript:load(<%=id%>,<%=s%>);" alt="<%=s%>" name="<%=s%>" src="pictures/stargrey.jpg"> <%
End If
Next
Else
For s = 1 to 5
If Clng(Media_Voti) > (s - 0.30) Then %>
<img alt="<%=s%>" name="<%=s%>" src="pictures/star.jpg"> <%
ElseIf Clng(Media_Voti) <= (s - 0.30) And Clng(Media_Voti) >= (s - 0.80) Then %>
<img alt="<%=s%>" name="<%=s%>" src="pictures/starhalf.jpg"> <%
ElseIf Clng(Media_Voti) < (s - 0.80) Then %>
<img alt="<%=s%>" name="<%=s%>" src="pictures/stargrey.jpg"> <%
End If
Next
End If
Response.Write( " (" & Voti & " voti)")
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
%>
</div>
</body>
</html>
codice:
<%
id = Request.QueryString("id")
newVoto = Request.QueryString("voto")
If newVoto > 5 Then
newVoto = 5
Elseif newVoto < 1 Then
newVoto = 1
Elseif Len(CInt(newVoto)) <> 1 Then
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & Server.MapPath("/mdb-database/articoli.mdb") & ";Jet OLEDB:Database"
Set RS = Server.CreateObject("ADODB.Recordset")
Sql = "select * from articoli WHERE id="& id
RS.Open Sql, Conn
Media_Voti = RS("Media_Voti")
Voti = RS("voti")
Voto_Intero = CDbl(Media_Voti * Voti) + newVoto
Voti = CInt(Voti) + 1
Media_Voti = Voto_Intero / Voti
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open Sql, Conn, 3, 3
RS("Voti") = Voti
RS("Media_Voti") = Media_Voti
RS.Update
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
nomeSession = "votato" & id
Session(nomeSession) = True
For s = 1 to 5
If Clng(Media_Voti) > (s - 0.30) Then %>
<img alt="<%=s%>" name="<%=s%>" src="pictures/star.jpg"> <%
ElseIf Clng(Media_Voti) <= (s - 0.30) And Clng(Media_Voti) >= (s - 0.80) Then %>
<img alt="<%=s%>" name="<%=s%>" src="pictures/starhalf.jpg"> <%
ElseIf Clng(Media_Voti) < (s - 0.80) Then %>
<img alt="<%=s%>" name="<%=s%>" src="pictures/stargrey.jpg"> <%
End If
Next
Response.Write( " (" & Voti & " voti)")
End If
%>
Ah ovviamente il primo codice richiama il secondo per esser sostituito da quest'ultimo