Jump to content
Fórum Script Brasil
  • 0

Ao Preencher o formulário já ir dando o total no ultimo campo


nedes

Question

Olá amigos Tenho um formulário que tem varios campos textfield portanto ao prencher os primeiros preciso que o Ultimo já va fazendo os cáculos e mostrando o resultado cossegui fazer isso com um script e m javascript mas preciso que seja em PHP por favor me ajudem.

<!-- função para calcular os campos do form -->

function Calcula() {

// pega o campo rodo.value

var rodo = eval(document.form1.rodo.value);

// pega o campo comp.value

var comp = eval(document.form1.comp.value);

var resu = rodo/4*(rodo/4)*(comp) / 10000

if (eval(document.form1.oco1.value)>0){

var oco1 = eval(document.form1.oco1.value);

var oco2 = eval(document.form1.oco2.value);

var desco = oco1*oco2*(comp) / 10000

var quantidade = resu-desco;

}

else

{

var quantidade = resu;

}

///num passa o valor para o campo quantidade

document.form1.quantidade.value = quantidade;

}

</script>

<td colspan="10"><form action="<?php echo $editFormAction; ?>" method="POST" name="form1" id="form1">

<table width="525">

<tr style="text-align: left">

<td width="116" align="left" class="texto1" style="text-align: left">Código:</td>

<td width="397"><label>

<input name="codigo" type="text" id="codigo" value="<?php echo $row_Recordset2['codigo']; ?>" size=10" onKeyPress= "return checkIt(event)"/>

</label></td>

</tr>

<tr>

<td class="texto1" style="text-align: left">Fornecedor:</td>

<td><label for="codfor"></label>

<input name="codfor" type="text" id="codfor" value="<?php echo $row_Recordset2['codfor]; ?>" size="10" onKeyPress= "return checkIt(event)"/></td>

</tr>

<tr>

<td class="texto1" style="text-align: left">Essência:</td>

<td><label>

<input name="essencia" type="text" id="essencia" onkeydown="this.value = this.value.toUpperCase();cancAcento()" onkeyup="this.value = this.value.toUpperCase()" value="<?php echo $row_Recordset2['essencia']; ?>" size=50"/></label></td>

</tr>

<tr>

<td class="texto1" style="text-align: left"><span class="texto1" style="text-align: left">Plaqueta</span>:</td>

<td><label>

<input name="plaqueta" type="text" id="plaqueta" value="<?php echo $row_Recordset2['plaqueta]; ?>" size="10" onKeyPress= "return checkIt(event)"/></label></td>

</tr>

<tr>

<td class="texto1" style="text-align: left"><span class="texto1" style="text-align: left">Comprimento</span>:</td>

<td><label>

<input name="comp" type="text" id="comp" onblur="Calcula();" value="<?php echo $row_Recordset2['comp']; ?>" size=10" onKeyPress= "return checkIt(event)"/></label></td>

</tr>

<tr>

<td class="texto1" style="text-align: left"><span class="texto1" style="text-align: left">Rodo</span>:</td>

<td><label>

<input name="rodo" type="text" id="rodo" onblur="Calcula();" value="<?php echo $row_Recordset2['rodo]; ?>" size="10"onKeyPress= "return checkIt(event)"/></label>

</tr>

<tr>

<td class="texto1" style="text-align: left"><span class="texto1" style="text-align: left">Oco - 1</span>:</td>

<td><label>

<input name="oco1" type="text" id="oco1" onblur="Calcula();" value="<?php echo $row_Recordset2['oco1']; ?>" size=10" onKeyPress= "return checkIt(event)"/></label>

</tr>

<tr>

<td class="texto1" style="text-align: left"><span class="texto1" style="text-align: left">Oco - 2</span>:</td>

<td><label>

<input name="oco2" type="text" id="oco2" onblur="Calcula();" value="<?php echo $row_Recordset2['oco2]; ?>" size="10" onKeyPress= "return checkIt(event)"/></label>

</tr>

<tr>

<td class="texto1" style="text-align: left"><span class="texto1" style="text-align: left">Quantidade</span>:</td>

<td><label>

<input name="quantidade" type="text" id="quantidade" onblur="Calcula(), KW_calcForm('quantidade',1000,-1,'#quantidade')" value="<?php echo $row_Recordset2['quantidade']; ?>" size=10" readonly="readonly" onKeyPress= "return checkIt(event)"/></label></td>

</tr>

<tr>

<td class="texto1" style="text-align: left">Preçod e Compra:</td>

<td><label>

<input name="vlcompra" type="text" id="vlcompra" value="<?php echo $row_Recordset2['vlcompra]; ?>" size="10" onKeyPress= "return checkIt(event)"/></label></td>

</tr>

<tr>

<td class="texto1" style="text-align: left">Data:</td>

<td><label>

<input name="data" type="text" id="data" value="<?php echo $data; ?>" size="10" onKeyPress= "return checkIt(event)"/></label></td>

</tr>

<tr class="texto1" style="text-align: left">

<td colspan="2" align="center"><input type="submit" name="gravar" id="gravar" value="Atualizar"/></td>

</tr>

</table>

<input type="hidden" name="MM_update" value="form1" />

</form></td>

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...