Ver Mensaje Individual
  #65 (permalink)  
Antiguo 25/04/2005, 12:25
Avatar de Saruman
Saruman
 
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 20 años, 11 meses
Puntos: 5
Calcular el Raiting

Esta función permite culcular el raiting de un producto, artículo o lo que queramos valorar... ESTILO AMAZON.COM

Utilización:

voto1 = 2
voto2 = 3
voto3 = 1
voto4 = 6
voto5 = 8

Total de votos = 20

total = RateIt(voto1, voto2, voto3, voto4, voto5)

response.write(total)

Resultado: 4

<img src="estrella_<%=(total)%>.gif" border="0">


Código:
Function RateIt(strEstrella1, strEstrella2, strEstrella3, strEstrella4, strEstrella5)
	strFullEstrella = 0
	strTotal_Estrellas = strEstrella1 + strEstrella2 + strEstrella3 + strEstrella4 + strEstrella5
	if strEstrella1 > 0 then strEstrella1 = strEstrella1 * 1
	if strEstrella2 > 0 then strEstrella2 = strEstrella2 * 2
	if strEstrella3 > 0 then strEstrella3 = strEstrella3 * 3
	if strEstrella4 > 0 then strEstrella4 = strEstrella4 * 4
	if strEstrella5 > 0 then strEstrella5 = strEstrella5 * 5
		
	if strTotal_Estrellas > 0 then
		strFullEstrella = (strEstrella1 + strEstrella2 + strEstrella3 + strEstrella4 + strEstrella5) / strTotal_Estrellas
		strFullEstrella = round(strFullEstrella,0)
		if strFullEstrella > 5 then strFullEstrella = 5
	end if
		
	RateIt = strFullEstrella
End Function
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.

Última edición por Saruman; 03/05/2005 a las 10:28