Ir para conteúdo

POWERED BY:

Arquivado

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

nivaldo_js

alto soma em tabela (array)

Recommended Posts

Caros !!Estou com grande dificuldade em criar!!Gostaria de um exemplo tipo quando o usuario digita o valor nos campos e no radopé fica somando e quando houver uma alteração no campo digitado a funcao recalcular !!Vcs poderiam me ajudar de como posso fazer isso, usando array ??Espero q vcs me ajudem !! obrigado !!!T++

Compartilhar este post


Link para o post
Compartilhar em outros sites

Usando Array eu não sei mas olha um exemplo.

 

<html><head><title>Somar</title></head><script language="JavaScript">function calcula(){var um = Number(document.somar.id_1.value);var dois = Number(document.somar.id_2.value);var tres = Number(document.somar.id_3.value);var quatro = Number(document.somar.id_4.value);var total = ((um) + (dois) + (tres) + (quatro));document.somar.total.value = total;}</script><body><form name="somar"><div align="center">  <center>  <table border="1" width="300" height="138">    <tr>      <td width="50%" height="19" align="center"><b>produto</b></td>      <td width="50%" height="19" align="center"><b>quantidade</b></td>    </tr>    <tr>      <td width="50%" height="19">bola</td>      <td width="50%" height="19" align="center"><input type="text" onBlur="calcula();" name="id_1" size="5" value=""></td>    </tr>    <tr>      <td width="50%" height="19">camisa</td>      <td width="50%" height="19" align="center"><input type="text" onBlur="calcula();" name="id_2" size="5" value=""></td>    </tr>    <tr>      <td width="50%" height="19">meião</td>      <td width="50%" height="19" align="center"><input type="text" onBlur="calcula();" name="id_3" size="5" value=""></td>    </tr>    <tr>      <td width="50%" height="19">tênis</td>      <td width="50%" height="19" align="center"><input type="text" onBlur="calcula();" name="id_4" size="5" value=""></td>    </tr>  </center>    <tr>      <td width="50%" height="7">        <p align="right"><b>Sub-total:</b></td>  <center>      <td width="50%" height="7" align="center"><input readonly type="text" name="total" size="8" value="0"></td>    </tr>  </table>  </center></div></form></body></html>

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.