<html> <head> <title><Excel in JS</title> </head> <body> <form name="form"> 1 <input type="text"name="n1"><br> 2 <input type="text"name="n2"><br> 3 <input type="text"name="n3"><br> <input type="button"value="Somar"onClick="soma()"> <script language="JavaScript"> <!-- function soma(){ resultado=0; for(i=0;i<3;i++) if(form.elements[i].value!=!isNaN && (form.elements[i].value!="")) resultado+=parseFloat(form.elements[i].value) alert(resultado); } //--> </script> </body> </html>
- Fórum WMO
- → Viewing Profile: Posts: gabows888
Community Stats
- Group Usuários
- Active Posts 39
- Profile Views 1738
- Member Title Turista
- Age Age Unknown
- Birthday Birthday Unknown
-
Sexo
Não informado
0
Neutral
User Tools
Friends
gabows888 hasn't added any friends yet.
Latest Visitors
-
Guest
04/11/2007, 05:06
Posts I've Made
In Topic: Como Somar Os Valores Das Caixas De Texto
20/07/2004, 23:55
tenta esse:
In Topic: Contador De Caracteres
15/07/2004, 13:09
tenta issu aki:
<form name="contatoForm"action=""> Nome: <input type="text"name="nome"id="form"><br> Assunto: <input type="text"name="assunto"id="assunto"><br> <textarea name="texto"id="texto"cols="45"rows="10"maxlength="150"onKeyPress="contador(this)"></textarea> <input type="button"value="Enviar"onClick="envia()"> <input type="button"value="Apagar"onClick="reset(this.form);contatoForm.resto.value=contatoForm.texto.maxlength"><br> Caracteres Restantes: <input type="text"name="resto"value="150"> </form> <script language="javascript"> function contador(texto){ resto=texto.maxlength-texto.value.length; contatoForm.resto.value=resto; if(resto<1){ alert("Limite do tamanho do texto!"); texto.value=texto.value.substring(0,texto.maxlength-1); contatoForm.texto.focus(); } } function envia(){ resto=contatoForm.texto.maxlength-contatoForm.texto.value.length; contatoForm.resto.value=resto; nome=contatoForm.nome.value; assunto=contatoForm.assunto.value; texto=contatoForm.texto.value; } </script>
In Topic: Gerador De Cpf Utilizando Substrings
10/07/2004, 14:10
galera, fiz umas alteraçoes :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Gerador de CPF >>> By Gabows#888 <<<</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> Entre com os 9 primeiros digitos de seu CPF ou quaisquer 9 digitos numericos q a partir deles o gerador cria um CPF valido. ENJOY!;) <form name="form"> <input type="text"name="CPF"id="cpf"maxlength="9"> <input type="button"value="Criar CPF"onClick="criar()"> </form> <script language="javascript"> //***********************************SCRIPT 100% DEVELOPED BY GABOWS#888***********************************\\ //if you're going to change or use this code, do not cut off these lines! //se voce vai alterar ou utilizar este codigo, nao retire estas linhas! //***********************************gabows888@yahoo.com.br***********************************\\ function validar(){ var cnpj=document.getElementById('cpf').value; if(form.CPF.value=="000000000"){ alert("Faz isso certo xxxxxx!"); return false; } if(cnpj.length!=9){ alert("Preencha os nove campos!"); return false; } if(isNaN(cnpj)){ alert("Preencha somente com dados numéricos!"); return false; } if(cnpj!=!isNaN){ for(i=0;i<=cnpj.length;i++) total=cnpj.length; campo01=0; campo02=0; n1=cnpj.substring(0,total-8); n2=cnpj.substring(1,total-7); n3=cnpj.substring(2,total-6); n4=cnpj.substring(3,total-5); n5=cnpj.substring(4,total-4); n6=cnpj.substring(5,total-3); n7=cnpj.substring(6,total-2); n8=cnpj.substring(7,total-1); n9=cnpj.substring(8,total); tt1=parseFloat((n1*10)+(n2*9)+(n3*8)+(n4*7)+(n5*6)+(n6*5)+(n7*4)+(n8*3)+(n9*2)); div1=(tt1%11); if(div1<2){ campo01+=0; } if(div1>=2){ campo01+=parseFloat(11-div1); } tt2=parseFloat((n1*11)+(n2*10)+(n3*9)+(n4*8)+(n5*7)+(n6*6)+(n7*5)+(n8*4)+(n9*3)+(campo01*2)); div2=(tt2%11); if(div2<2){ campo02+=0; } if(div2>=2){ campo02+=parseFloat(11-div2); } alert(n1+''+n2+''+n3+''+n4+''+n5+''+n6+''+n7+''+n8+''+n9+'-'+campo01+''+campo02); return; } } function gera(n){ num=Math.round(Math.random()*n); return num; } function create(){ d1=""; d2=""; n1=gera(9); n2=gera(9); n3=gera(9); n4=gera(9); n5=gera(9); n6=gera(9); n7=gera(9); n8=gera(9); n9=gera(9); tt1=parseFloat((n1*10)+(n2*9)+(n3*8)+(n4*7)+(n5*6)+(n6*5)+(n7*4)+(n8*3)+(n9*2)); t1=(tt1%11); if(t1<2){ d1+=0; } if(t1>=2){ d1+=parseFloat(11-t1); } tt2=parseFloat((n1*11)+(n2*10)+(n3*9)+(n4*8)+(n5*7)+(n6*6)+(n7*5)+(n8*4)+(n9*3)+(d1*2)); t2=(tt2%11); if(t2<2){ d2+=0; } if(t2>=2){ d2+=parseFloat(11-t2); } form.CPF.value=n1+''+n2+''+n3+'.'+n4+''+n5+''+n6+'.'+n7+''+n8+''+n9+'-'+d1+''+d2; } function criar(){ if(form.CPF.value==""){ return create(); } if(form.CPF.value!=""){ return validar(); } } </script> </body> </html>
In Topic: Ajuda Em Somar As Caixas De Texto
06/07/2004, 15:14
seria isso? :
<form name="form"> Produto 1 <input type="text"name="n1"><br> Produto 2 <input type="text"name="n2"><br> Produto 3 <input type="text"name="n3"><br> <input type="button"value="Somar"onClick="soma()"> <script language="JavaScript"> <!-- function soma(){ resultado=0; for(i=0;i<3;i++) if(form.elements[i].value!=!isNaN && (form.elements[i].value!="")) resultado+=parseFloat(form.elements[i].value) alert(resultado); } //--> </script>
In Topic: Contador De Caracteres
04/07/2004, 23:02
galera, o meu tah bem parecido com o seus aki, mas nao sei se vcs perceberam, mas se o cara dah BackSpace ele nao aumenta (pelo menos no meu script) o valor de caracteres q ainda cabem...ele se ajusta qdo o cara digita algo novamente, mas se o cara aperta BackSpace e para de digitar, ele fica errado...se alguem souber como arrumar...
Eu tentei assim:
...
rest=formulario.campoResto.maxlength-formulario.campoResto.value.length;
if(event.keyPress==8){
formulario.campoResto.value=rest+1;
}
---
mas ainda nao deu certo...sei lah, pela logica nao precisaria fazer isso, pois eu fiz assim:
Eu tentei assim:
...
rest=formulario.campoResto.maxlength-formulario.campoResto.value.length;
if(event.keyPress==8){
formulario.campoResto.value=rest+1;
}
---
mas ainda nao deu certo...sei lah, pela logica nao precisaria fazer isso, pois eu fiz assim:
<textarea name="texto"id="texto"cols="45"rows="10"maxlength="150"onkeypress="contador(this)"></textarea> <input type="button"value="Enviar"onclick="envia()"><br> <input type="text"name="resto"> </form> <script language="javascript"> function contador(texto){ resto=texto.maxlength-texto.value.length; if(event.keyPress==8){ contatoForm.resto.value=resto+1; } contatoForm.resto.value=resto; if(resto<=0){ alert("Limite do tamanho do texto!"); contatoForm.texto.focus(); } } </script>pela logica o 'onkeypress' deveria incluir o BackSpace, nao?
- Fórum WMO
- → Viewing Profile: Posts: gabows888
- Privacy Policy
- Regras ·