Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

arldin

Gostaria de saber a onde estou errando?

Recommended Posts

Amigos estou com um pequeno poblema tenhos este formulario de calculo, e esta dando o sequinte erro

Quando eu escolho a qtd ele retona no valor certo mais no total geral ele me da a sequinte mensagem

"R$NaN.NaN"

Ele não esta me dando o valor total alquem pode me amostra a onde estou erando por favor

seque o script e o html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>Formulario de Pedido</TITLE>

<META http-equiv=Content-Type content="text/html; charset=windows-1252">

<script language=javascript>

 

var nItens = 5;

 

function recalculaTotais (frm)

{

var total = 0;

for (var i = 0; i < nItens; i++)

{

frm.total.value =forma(Math.round(frm.preco.value * frm.quant.value * 0.1)/0.1)

total = forma(Math.floor(frm.total.value*0.1)/0.1);

}

frm.totalgeral.value = forma(total)

}

function forma(num){

reais=Math.floor(num)

cents=Math.round((num-reais)*100)

texto="R$"+reais+"."

if(cents<10){

texto=texto+"0"

}

texto=texto+cents

return texto

}

//-->

</SCRIPT>

 

<META content="MSHTML 6.00.2900.3354" name=GENERATOR>

<FORM id=formEmail name=formEmail action=envia1.asp method=post></HEAD>

<BODY background=Arldinartfest5/index_arquivos/image306.gif>

<H1 TYPE="Hidden">Formulario de Pedido<FONT color=#0000ff

size=1></TD> </FONT><TD width="150"></TD></TR><FONT size=1><FONT

color=#0000ff> </FONT></FONT></H1><FORM name="f">

<TABLE style="WIDTH: 599px; HEIGHT: 315px">

<TBODY>

<TR>

<TH>Imagen

<TH>Códico

<TH>Produto

<TH>Preço

<TH>Quantidade

<TH>Total

<TR>

<TD><IMG style="WIDTH: 40px; HEIGHT: 31px" height=35 alt=""

src="Arldin/baixados1/001.JPG" width=47>

<TD>Cód.001

<TD TYPE="Hidden" READONLY="0">Homem Aranha

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[0].focus() type=hidden size=6 value=10.00

name=preco1>

<TD SIZE="8"><INPUT id=quant onchange=recalculaTotais(this.form) size=4

name=quant1>

<TD><INPUT id=total onfocus=this.form.quant[1].focus() size=8 value=R$0.00

name=total1>

<TR>

<TD><IMG style="WIDTH: 41px; HEIGHT: 33px" height=31 alt="" hspace=0

src="Arldin/baixados1/002.JPG" width=40 border=0>

<TD>Cód.002

<TD READONLY="1" SIZE="8" VALUE="10.00">Flamengo

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[1].focus() type=hidden size=6 value=10.00

name=preco2>

<TD SIZE="8" VALUE="R$0.00"><INPUT id=quant

onchange=recalculaTotais(this.form) size=4 name=quant2>

<TD><INPUT id=total onfocus=this.form.quant[2].focus() size=8 value=R$0.00

name=total2>

<TR>

<TD><IMG style="WIDTH: 37px; HEIGHT: 36px" height=31 alt="" hspace=0

src="Arldin/baixados1/003.jpg" width=40 border=0>

<TD>Cód.003

<TD>Vasco

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[2].focus() type=hidden size=6 value=10.00

name=preco3>

<TD SIZE="8"><INPUT id=quant onchange=recalculaTotais(this.form) size=4

name=quant3>

<TD><INPUT id=total onfocus=this.form.quant[3].focus() size=8 value=R$0.00

name=total3>

<TR>

<TD><IMG style="WIDTH: 35px; HEIGHT: 36px" height=31 alt="" hspace=0

src="Arldin/baixados1/004.jpg" width=40 border=0>

<TD>Cód.004

<TD>Botafogo

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[3].focus() type=hidden size=6 value=10.00

name=preco4>

<TD SIZE="8"><INPUT id=quant onchange=recalculaTotais(this.form) size=4

name=quant4>

<TD><INPUT id=total onfocus=this.form.quant[4].focus() size=8 value=R$0.00

name=total4>

<TR>

<TD><IMG style="WIDTH: 40px; HEIGHT: 39px" height=31 alt="" hspace=0

src="Arldin/baixados1/005.jpg" width=40 border=0>

<TD>Cód.005

<TD>Fluminense

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[4].focus() type=hidden size=6 value=10.00

name=preco5>

<TD SIZE="8"><INPUT id=quant onchange=recalculaTotais(this.form) size=4

name=quant5>

<TD><INPUT id=total onfocus=this.form.quant[5].focus() size=8 value=R$0.00

name=total5>

<TR>

<TD></TD>

<TD></TD>

<TD></TD>

<TD></TD>

<TD><STRONG>Total :</STRONG> </TD>

<TD><INPUT id=totalgeral onfocus=this.form.bot.focus() size=8 value=R$0.00

name=totalgeral></TD></TR></TBODY></TABLE>

<P> </P>

<P> </P>

<P></FORM></P></BODY></HTML>

Desde ja agradeço a colaboração

Compartilhar este post


Link para o post
Compartilhar em outros sites

use o parseInt e o parseFloat para floats para passar as strings para numero faça isso sempre que for pegar uma valor e calcular..

 

t+

Compartilhar este post


Link para o post
Compartilhar em outros sites

Oi amigo gostaria que você se possivel me explicar uma pouco melhor, pois ainda sou leigo no assunto,

a onde eu uso o parseFloat e o parseInt

Arldin

Obrigado desde ja

Compartilhar este post


Link para o post
Compartilhar em outros sites

da uma olhada

 

<script language=javascript>

var nItens = 5;

function recalculaTotais(frm)
{
var total = 0;
for (var i = 0; i < nItens; i++)
{
	frm.total[i].value = forma(Math.round(frm.preco[i].value * frm.quant[i].value * 0.1)/0.1)
	total+= parseFloat(frm.total[i].value.replace("R$",""));
}
frm.totalgeral.value = forma(total)

}
function forma(num){

	reais = Math.floor(num);
	cents = Math.round((num-reais)*100);
	texto = "R$" + reais + ".";
	if(cents < 10){
		texto = texto + "0";
	}
	texto = texto + cents;
	
	return texto;
}
//-->
</SCRIPT>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Amigos estou com um pequeno poblema tenhos este formulario de calculo, e esta dando o sequinte erro

Quando eu escolho a qtd ele retona no valor certo mais no total geral ele me da a sequinte mensagem

"R$NaN.NaN"

Ele não esta me dando o valor total alquem pode me amostra a onde estou erando por favor

seque o script e o html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>Formulario de Pedido</TITLE>

<META http-equiv=Content-Type content="text/html; charset=windows-1252">

<script language=javascript>

 

var nItens = 5;

 

function recalculaTotais (frm)

{

var total = 0;

for (var i = 0; i < nItens; i++)

{

frm.total.value =forma(Math.round(frm.preco.value * frm.quant.value * 0.1)/0.1)

total = forma(Math.floor(frm.total.value*0.1)/0.1);

}

frm.totalgeral.value = forma(total)

}

function forma(num){

reais=Math.floor(num)

cents=Math.round((num-reais)*100)

texto="R$"+reais+"."

if(cents<10){

texto=texto+"0"

}

texto=texto+cents

return texto

}

//-->

</SCRIPT>

 

<META content="MSHTML 6.00.2900.3354" name=GENERATOR>

<FORM id=formEmail name=formEmail action=envia1.asp method=post></HEAD>

<BODY background=Arldinartfest5/index_arquivos/image306.gif>

<H1 TYPE="Hidden">Formulario de Pedido<FONT color=#0000ff

size=1></TD> </FONT><TD width="150"></TD></TR><FONT size=1><FONT

color=#0000ff> </FONT></FONT></H1><FORM name="f">

<TABLE style="WIDTH: 599px; HEIGHT: 315px">

<TBODY>

<TR>

<TH>Imagen

<TH>Códico

<TH>Produto

<TH>Preço

<TH>Quantidade

<TH>Total

<TR>

<TD><IMG style="WIDTH: 40px; HEIGHT: 31px" height=35 alt=""

src="Arldin/baixados1/001.JPG" width=47>

<TD>Cód.001

<TD TYPE="Hidden" READONLY="0">Homem Aranha

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[0].focus() type=hidden size=6 value=10.00

name=preco1>

<TD SIZE="8"><INPUT id=quant onchange=recalculaTotais(this.form) size=4

name=quant1>

<TD><INPUT id=total onfocus=this.form.quant[1].focus() size=8 value=R$0.00

name=total1>

<TR>

<TD><IMG style="WIDTH: 41px; HEIGHT: 33px" height=31 alt="" hspace=0

src="Arldin/baixados1/002.JPG" width=40 border=0>

<TD>Cód.002

<TD READONLY="1" SIZE="8" VALUE="10.00">Flamengo

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[1].focus() type=hidden size=6 value=10.00

name=preco2>

<TD SIZE="8" VALUE="R$0.00"><INPUT id=quant

onchange=recalculaTotais(this.form) size=4 name=quant2>

<TD><INPUT id=total onfocus=this.form.quant[2].focus() size=8 value=R$0.00

name=total2>

<TR>

<TD><IMG style="WIDTH: 37px; HEIGHT: 36px" height=31 alt="" hspace=0

src="Arldin/baixados1/003.jpg" width=40 border=0>

<TD>Cód.003

<TD>Vasco

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[2].focus() type=hidden size=6 value=10.00

name=preco3>

<TD SIZE="8"><INPUT id=quant onchange=recalculaTotais(this.form) size=4

name=quant3>

<TD><INPUT id=total onfocus=this.form.quant[3].focus() size=8 value=R$0.00

name=total3>

<TR>

<TD><IMG style="WIDTH: 35px; HEIGHT: 36px" height=31 alt="" hspace=0

src="Arldin/baixados1/004.jpg" width=40 border=0>

<TD>Cód.004

<TD>Botafogo

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[3].focus() type=hidden size=6 value=10.00

name=preco4>

<TD SIZE="8"><INPUT id=quant onchange=recalculaTotais(this.form) size=4

name=quant4>

<TD><INPUT id=total onfocus=this.form.quant[4].focus() size=8 value=R$0.00

name=total4>

<TR>

<TD><IMG style="WIDTH: 40px; HEIGHT: 39px" height=31 alt="" hspace=0

src="Arldin/baixados1/005.jpg" width=40 border=0>

<TD>Cód.005

<TD>Fluminense

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[4].focus() type=hidden size=6 value=10.00

name=preco5>

<TD SIZE="8"><INPUT id=quant onchange=recalculaTotais(this.form) size=4

name=quant5>

<TD><INPUT id=total onfocus=this.form.quant[5].focus() size=8 value=R$0.00

name=total5>

<TR>

<TD></TD>

<TD></TD>

<TD></TD>

<TD></TD>

<TD><STRONG>Total :</STRONG> </TD>

<TD><INPUT id=totalgeral onfocus=this.form.bot.focus() size=8 value=R$0.00

name=totalgeral></TD></TR></TBODY></TABLE>

<P> </P>

<P> </P>

<P></FORM></P></BODY></HTML>

Desde ja agradeço a colaboração

Compartilhar este post


Link para o post
Compartilhar em outros sites

Amigos estou com um pequeno poblema tenhos este formulario de calculo, e esta dando o sequinte erro

Quando eu escolho a qtd ele retona no valor certo mais no total geral ele me da a sequinte mensagem

"R$NaN.NaN"

Ele não esta me dando o valor total alquem pode me amostra a onde estou erando por favor

seque o script e o html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>Formulario de Pedido</TITLE>

<META http-equiv=Content-Type content="text/html; charset=windows-1252">

<script language=javascript>

 

var nItens = 5;

 

function recalculaTotais (frm)

{

var total = 0;

for (var i = 0; i < nItens; i++)

{

frm.total.value =forma(Math.round(frm.preco.value * frm.quant.value * 0.1)/0.1)

total = forma(Math.floor(frm.total.value*0.1)/0.1);

}

frm.totalgeral.value = forma(total)

}

function forma(num){

reais=Math.floor(num)

cents=Math.round((num-reais)*100)

texto="R$"+reais+"."

if(cents<10){

texto=texto+"0"

}

texto=texto+cents

return texto

}

//-->

</SCRIPT>

 

<META content="MSHTML 6.00.2900.3354" name=GENERATOR>

<FORM id=formEmail name=formEmail action=envia1.asp method=post></HEAD>

<BODY background=Arldinartfest5/index_arquivos/image306.gif>

<H1 TYPE="Hidden">Formulario de Pedido<FONT color=#0000ff

size=1></TD> </FONT><TD width="150"></TD></TR><FONT size=1><FONT

color=#0000ff> </FONT></FONT></H1><FORM name="f">

<TABLE style="WIDTH: 599px; HEIGHT: 315px">

<TBODY>

<TR>

<TH>Imagen

<TH>Códico

<TH>Produto

<TH>Preço

<TH>Quantidade

<TH>Total

<TR>

<TD><IMG style="WIDTH: 40px; HEIGHT: 31px" height=35 alt=""

src="Arldin/baixados1/001.JPG" width=47>

<TD>Cód.001

<TD TYPE="Hidden" READONLY="0">Homem Aranha

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[0].focus() type=hidden size=6 value=10.00

name=preco1>

<TD SIZE="8"><INPUT id=quant onchange=recalculaTotais(this.form) size=4

name=quant1>

<TD><INPUT id=total onfocus=this.form.quant[1].focus() size=8 value=R$0.00

name=total1>

<TR>

<TD><IMG style="WIDTH: 41px; HEIGHT: 33px" height=31 alt="" hspace=0

src="Arldin/baixados1/002.JPG" width=40 border=0>

<TD>Cód.002

<TD READONLY="1" SIZE="8" VALUE="10.00">Flamengo

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[1].focus() type=hidden size=6 value=10.00

name=preco2>

<TD SIZE="8" VALUE="R$0.00"><INPUT id=quant

onchange=recalculaTotais(this.form) size=4 name=quant2>

<TD><INPUT id=total onfocus=this.form.quant[2].focus() size=8 value=R$0.00

name=total2>

<TR>

<TD><IMG style="WIDTH: 37px; HEIGHT: 36px" height=31 alt="" hspace=0

src="Arldin/baixados1/003.jpg" width=40 border=0>

<TD>Cód.003

<TD>Vasco

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[2].focus() type=hidden size=6 value=10.00

name=preco3>

<TD SIZE="8"><INPUT id=quant onchange=recalculaTotais(this.form) size=4

name=quant3>

<TD><INPUT id=total onfocus=this.form.quant[3].focus() size=8 value=R$0.00

name=total3>

<TR>

<TD><IMG style="WIDTH: 35px; HEIGHT: 36px" height=31 alt="" hspace=0

src="Arldin/baixados1/004.jpg" width=40 border=0>

<TD>Cód.004

<TD>Botafogo

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[3].focus() type=hidden size=6 value=10.00

name=preco4>

<TD SIZE="8"><INPUT id=quant onchange=recalculaTotais(this.form) size=4

name=quant4>

<TD><INPUT id=total onfocus=this.form.quant[4].focus() size=8 value=R$0.00

name=total4>

<TR>

<TD><IMG style="WIDTH: 40px; HEIGHT: 39px" height=31 alt="" hspace=0

src="Arldin/baixados1/005.jpg" width=40 border=0>

<TD>Cód.005

<TD>Fluminense

<TD TYPE="Hidden">R$ 10,00<INPUT id=preco

onfocus=this.form.quant[4].focus() type=hidden size=6 value=10.00

name=preco5>

<TD SIZE="8"><INPUT id=quant onchange=recalculaTotais(this.form) size=4

name=quant5>

<TD><INPUT id=total onfocus=this.form.quant[5].focus() size=8 value=R$0.00

name=total5>

<TR>

<TD></TD>

<TD></TD>

<TD></TD>

<TD></TD>

<TD><STRONG>Total :</STRONG> </TD>

<TD><INPUT id=totalgeral onfocus=this.form.bot.focus() size=8 value=R$0.00

name=totalgeral></TD></TR></TBODY></TABLE>

<P> </P>

<P> </P>

<P></FORM></P></BODY></HTML>

Desde ja agradeço a colaboração

 

Resolvido

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.