PUBLICIDADE
Este código tem nota
9

Autor

hneemias

Hneemias Souza Barbosa

membro deste dezembro de 2006

Tags

Compartilhe e guarde

  • Rec6
  • StumbleUpon
  • ueba
  • linkk
  • dihitt
  • linkloko
  • linkto
  • Technorati
  • Simpy
  • del.icio.us
  • Faves: Fave It!

PUBLICIDADE

Enquete

Google Chrome OS ameaça a liderança do Windows da Microsoft?

Seleção com estrelas igual ao Orkut em ASP


Com este código é possível fazer a criação de uma seleção com 5 estrelas do mesmo estilo o que existe no site Orkut para rankear os amigos.

Para utilizar em seu site você deve utilizar a função chamada "getEstrelas", nesta função existem 2 parâmetros:
- O primeiro parâmetro passamos o número de estrelas que já estará selecionada por padrão.
- O segundo parâmetro indica o nome do campo "hidden" que deverá ser criado para armazenar a quantidade de estrelas que estão marcadas, caso seja passado em branco a função não criará o hidden e as estrelas não poderão ser marcadas.

Ao utilizar esta função as estrelas funcionarão dentro de um formulário que já que existirá um campo hidden que fará o controle das estrelas.

------------

Este código é uma adptação que fiz do artigo http://www.codigofonte.com.br/codigo/php/imagens/criar-uma-selecao-com-estrelas-igual-ao-orkut .
<%
function getEstrelas(numero_estrelas, nome_hidden_estrelas)
	retorno = ""
	i=0
	if (nome_hidden_estrelas = "") then
		for i = 0 to 4 
			if (numero_estrelas<=i) then
				retorno = "<img src=""imagens/estrela2.gif"" width=""16"" height=""16"">"
			else
				retorno = "<img src=""imagens/estrela1.gif"" width=""16"" height=""16"">"
			end if
		next
		else
		if (numero_estrelas = 0) then
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""1 estrelas"" id=""star1"" onclick=""changeStar(this, 1, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""2 estrelas"" id=""star2"" onclick=""changeStar(this, 2, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""3 estrelas"" id=""star3"" onclick=""changeStar(this, 3, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""4 estrelas"" id=""star4"" onclick=""changeStar(this, 4, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""5 estrelas"" id=""star5"" onclick=""changeStar(this, 5, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
		elseif (numero_estrelas = 1) then
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""1 estrelas"" id=""star1"" onclick=""changeStar(this, 1, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""2 estrelas"" id=""star2"" onclick=""changeStar(this, 2, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""3 estrelas"" id=""star3"" onclick=""changeStar(this, 3, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""4 estrelas"" id=""star4"" onclick=""changeStar(this, 4, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""5 estrelas"" id=""star5"" onclick=""changeStar(this, 5, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
		elseif (numero_estrelas = 2) then
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""1 estrelas"" id=""star1"" onclick=""changeStar(this, 1, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""2 estrelas"" id=""star2"" onclick=""changeStar(this, 2, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""3 estrelas"" id=""star3"" onclick=""changeStar(this, 3, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""4 estrelas"" id=""star4"" onclick=""changeStar(this, 4, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""5 estrelas"" id=""star5"" onclick=""changeStar(this, 5, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
		elseif (numero_estrelas = 3) then
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""1 estrelas"" id=""star1"" onclick=""changeStar(this, 1, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""2 estrelas"" id=""star2"" onclick=""changeStar(this, 2, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""3 estrelas"" id=""star3"" onclick=""changeStar(this, 3, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""4 estrelas"" id=""star4"" onclick=""changeStar(this, 4, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""5 estrelas"" id=""star5"" onclick=""changeStar(this, 5, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
		elseif (numero_estrelas = 4) then
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""1 estrelas"" id=""star1"" onclick=""changeStar(this, 1, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""2 estrelas"" id=""star2"" onclick=""changeStar(this, 2, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""3 estrelas"" id=""star3"" onclick=""changeStar(this, 3, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""4 estrelas"" id=""star4"" onclick=""changeStar(this, 4, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela2.gif"" aceso=""0"" alt=""5 estrelas"" id=""star5"" onclick=""changeStar(this, 5, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
		elseif (numero_estrelas = 5) then
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""1 estrelas"" id=""star1"" onclick=""changeStar(this, 1, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""2 estrelas"" id=""star2"" onclick=""changeStar(this, 2, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""3 estrelas"" id=""star3"" onclick=""changeStar(this, 3, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""4 estrelas"" id=""star4"" onclick=""changeStar(this, 4, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
			retorno = retorno &  "<img src=""imagens/estrela1.gif"" aceso=""1"" alt=""5 estrelas"" id=""star5"" onclick=""changeStar(this, 5, 'estrelas')"" style=""cursor:hand"" width=""16"" height=""16"">"
end if
end if
			retorno = retorno &  "<input type=""hidden"" id=""estrelas"" name=""nome_hidden_estrelas"" value="&numero_estrelas&">"		
	getEstrelas = retorno
end function
%>


<html>
<head>
<title>Exemplo ESTRELAS - RoccoFroes.com</title>
<script language="javascript" src="estrelas.js"></script>
</head>
<body>

<b>Exemplo de utilização do STAR</b><br><br>
<% = getEstrelas(0, "estrelas") %>

</body>
</html>

ArquivoTipoTamanhoHits 
imagens.rarArquivo RAR1,3 Kb424Baixar o Arquivo
estrelas.jsArquivo JS1,7 Kb388Baixar o Arquivo
default.aspArquivo ASP6,8 Kb397Baixar o Arquivo
Sim   Não   Este código foi útil para você?
NotaComentário
9
alberto12 comentou em 24/8/2009

Excelente

Bem desenvolvido e detalhado, otimo para iniciantas
Regras:
Os comentários seguem as seguintes regras:
  • Todos os comentários são enviados por membros cadastrados no site.
  • A pontuação de comentários de conteúdo do próprio membro não serão computados.
  • Os comentários serão pré-aprovados, porém a equipe do site revisará o conteúdo de todos os comentários podendo ser invalidados (inclusive a pontuação).
  • Os comentários precisam ter, obrigatóriamente, coerência sobre o conteúdo que será comentado.
  • O membro que atingir 5 comentários invalidados não poderá mais comentar dentro do site. Com isso o membro não poderá mais ganhar pontos com comentários.
  • Há um limite de 10 comentários por dia para cada membro.
  • Qualquer comentário após ter sido publicado poderá ser retirado através da opção ( denunciar)

Comente

     (ainda não tem cadastro? clique aqui!)


Máximo de 30 caracteres

Máximo de 255 caracteres
 

R&W Consulting - Soluções Web Hospedagem UOL HOST PagSeguro - solução para pagamentos online
© 2006-2009 R&W Informática Ltda. - Todos os direitos reservados.