Jump to content
Fórum Script Brasil
  • 0

pegar array do form e preencher array js


Carlos Rocha

Question

Na verdade o que acontece é que eu tenho o seguinte:

<fieldset>
          <legend>Itens&nbsp;</legend>
            <table class="pedidos">
              <tr>
                 <th></th>
                 <th>QTD</th>
                 <td class="colSep"></td>
                 <th></th>
                 <th>QTD</th>
              </tr>
              <tr>
                <td>Hossomaki</td>
                <td class="qtd"><input type="text" name="quant[]" size="3" value="" /></td>
                <td></td>
                <td>Saschimi Salm&atilde;o</td>
                <td class="qtd"><input type="text" name="quant[]" size="3" value="" /></td>
              </tr>
              <tr>
                <td>Niguri</td>
                <td class="qtd"><input type="text" name="quant[]" size="3" value="" /></td>
                <td></td>
                <td>Saschimi Kani</td>
                <td class="qtd"><input type="text" name="quant[]" size="3" value="" /></td>
              </tr>
              <tr>
                <td>Frango Xadrez</td>
                <td class="qtd"><input type="text" name="quant[]" size="3" value="" /></td>
                <td></td>
                <td>Rolinho Primavera</td>
                <td class="qtd"><input type="text" name="quant[]" size="3" value="" /></td>
              </tr>
              <tr>
                <td>Frango Agridoce</td>
                <td class="qtd"><input type="text" name="quant[]" size="3" value="" /></td>
                <td></td>
                <td>BulGoGui</td>
                <td class="qtd"><input type="text" name="quant[]" size="3" value="" /></td>
              </tr>
              <tr>
                <td colspan="5" class="linSep"></td>
              </tr>
              <tr>
                <td><input type="button" value="Calcular" onClick="CalculaPreco(document.pedidos.quant)" /></td>
                <td colspan="4" class="qtd">Valor Total:&nbsp;&nbsp;&nbsp;R$<input type="text" name="total" size="5"></td>
              </tr>
            </table>
            </fieldset> <br/>

Daí, na função js, preciso fazer o seguinte:

o produto da primeira name="quant[]" vale x reais, o da segunda, y reais. Eu tenho uma tabela com o preço de cada uma das name="quant[]".

Lá no js preciso fazer assim:

Se o indice da quant[] que veio do form for igual a 0, então, valor_semitotal=quant[0]*1,80.

Se o indice da quant[] que veio do form for igual a 1, então, valor_semitotal=quant[0]*2,20.

..

Assim por diante. Até terminar.

Daí, pegar o somatório de todos os valor_semitotal e entregar para o total e exibir em um label.

Como fazer isso?

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...