USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Dicas

  ASP - Active Server Page    (Miscelâneas)

Título da Dica:  Calculando Porcentagem (Similar ao Sistema de Enquetes)
Postada em 2/10/2003 por ^HEAVY-METAL^            
Esta dica, é um script que calcula os valores inseridos no campos e transforma em porcentagem. É bastante util para o calculo de procentagem dos posts em fórums.

Segue a dica:

<%
dim percent1, percent2, percent3, total, total1, total2, total3

'Aqui o script verifica se há algum valor inserido no campo, se não, ele imprime uma mensagem de erro
if Request.Form("percent1") = "" OR Request.Form("percent2") = "" OR Request.Form("percent3") = "" then
Response.Write "Digite os numeros nos campos!"
else
'Recebe os 3 valores inseridos no campos
percent1 = Request.Form("percent1")
percent2 = Request.Form("percent2")
percent3 = Request.Form("percent3")
'O script calcula os valores das variáveis
total = Cint(percent1) + Cint(percent2) + Cint(percent3)
total1 = Cint(percent1 / total * 100) & "%"
total2 = Cint(percent2 / total * 100) & "%"
total3 = Cint(percent3 / total * 100) & "%"
End if
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="porcentagem" method="post" action="percent.asp">
<table width="30%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="31%">Numero1:</td>
<td width="69%">
<input type="text" name="percent1" size="5">
</td>
</tr>
<tr>
<td width="31%">Numero2:</td>
<td width="69%">
<input type="text" name="percent2" size="5">
</td>
</tr>
<tr>
<td width="31%">Numero3:</td>
<td width="69%">
<input type="text" name="percent3" size="5">
</td>
</tr>
<tr>
<td width="31%">Porcentagem:</td>
<td width="69%">Opção1: <%=total1%>

Opção2: <%=total2%>

Opção3: <%=total3%></td>
</tr>
<tr>
<td width="31%"> </td>
<td width="69%">
<input type="submit" name="Submit" value="Envia">
</td>
</tr>
</table>
</form>
</body>
</html>

T+,
 


CyberWEB Network Ltda.    © Copyright 2000-2024   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página