cdfree Postado Junho 10, 2012 Denunciar Share Postado Junho 10, 2012 não estou consuguindo incremenata variável $_POST[ ];segue código:<?php# conexÆo com banco de dados$db = mysql_connect("127.0.0.1","brasilia","200230");$link = mysql_select_db("orcamento",$db);$nome = $_POST['vl1'];$contrato = '027/2012';if($nome != 0){for ($i=1; $i<=12;$i++){$incluir = mysql_query("INSERT INTO debito (contrato, data, valor) VALUES ('$contrato', '$i/2012' , $_POST['vl'.$i];)");}}?>formulário de envio:<script>function repete(){ var valor = document.getElementById("info").value; { for(i=1; i<=12;i++) document.getElementById("vl"+i).value = valor;}}function soma(){ var c1 = parseFloat(document.getElementById("info").value); var c2 = parseFloat(document.getElementById("vl1").value); var c3 = parseFloat(document.getElementById("vl2").value); var c4 = parseFloat(document.getElementById("vl3").value); var c5 = parseFloat(document.getElementById("vl4").value); var c6 = parseFloat(document.getElementById("vl5").value); var c7 = parseFloat(document.getElementById("vl6").value); var c8 = parseFloat(document.getElementById("vl7").value); var c9 = parseFloat(document.getElementById("vl8").value); var c10 = parseFloat(document.getElementById("vl9").value); var c11 = parseFloat(document.getElementById("vl10").value); var c12 = parseFloat(document.getElementById("vl11").value); if (isNaN(c1)) c1 = 0; if (isNaN(c2)) c2 = 0; if (isNaN(c3)) c3 = 0; if (isNaN(c4)) c4 = 0; if (isNaN(c5)) c5 = 0; if (isNaN(c6)) c6 = 0; if (isNaN(c7)) c7 = 0; if (isNaN(c8)) c8 = 0; if (isNaN(c9)) c9 = 0; if (isNaN(c10)) c10 = 0; if (isNaN(c11)) c11 = 0; if (isNaN(c12)) c12 = 0; var soma = (c1+c2+c3+c4+c5+c6+c7+c8+c9+c10+c11+c12); document.getElementById("total").value = parseFloat(soma.toFixed(2));} </script><form action=script.php method=post><table border="0"><tr><td> <input type=text id="info" onkeyup="repete();soma();" style='background:#ccc;'><br> <input type=text id="vl1" onkeyup="soma();"><br> <input type=text id="vl2" onkeyup="soma();"><br> <input type=text id="vl3" onkeyup="soma();"><br> </td> <td> <input type=text id="vl4" onkeyup="soma();"><br> <input type=text id="vl5" onkeyup="soma();"><br> <input type=text id="vl6" onkeyup="soma();"><br> <input type=text id="vl7" onkeyup="soma();"><br> </td> <td> <input type=text id="vl8" onkeyup="soma();"><br> <input type=text id="vl9" onkeyup="soma();"><br> <input type=text id="vl10" onkeyup="soma();"><br> <input type=text id="vl11" onkeyup="soma();"><br> <td></tr><tr><td colspan="2">VALOR TOTAL DO CONTRATO</td> <td align="right"><input type=text id="total" style='background:#ccc;'> </td> </tr></table><input type=submit value=gravar><input type=reset value=Limpar></form> Citar Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
cdfree
não estou consuguindo incremenata variável $_POST[ ];
segue código:
<?php
# conexÆo com banco de dados
$db = mysql_connect("127.0.0.1","brasilia","200230");
$link = mysql_select_db("orcamento",$db);
$nome = $_POST['vl1'];
$contrato = '027/2012';
if($nome != 0)
{
for ($i=1; $i<=12;$i++)
{
$incluir = mysql_query("INSERT INTO debito (contrato, data, valor) VALUES ('$contrato', '$i/2012' , $_POST['vl'.$i];)");
}}
?>
formulário de envio:
<script>
function repete()
{
var valor = document.getElementById("info").value; { for(i=1; i<=12;i++) document.getElementById("vl"+i).value = valor;}
}
function soma()
{
var c1 = parseFloat(document.getElementById("info").value);
var c2 = parseFloat(document.getElementById("vl1").value);
var c3 = parseFloat(document.getElementById("vl2").value);
var c4 = parseFloat(document.getElementById("vl3").value);
var c5 = parseFloat(document.getElementById("vl4").value);
var c6 = parseFloat(document.getElementById("vl5").value);
var c7 = parseFloat(document.getElementById("vl6").value);
var c8 = parseFloat(document.getElementById("vl7").value);
var c9 = parseFloat(document.getElementById("vl8").value);
var c10 = parseFloat(document.getElementById("vl9").value);
var c11 = parseFloat(document.getElementById("vl10").value);
var c12 = parseFloat(document.getElementById("vl11").value);
if (isNaN(c1)) c1 = 0;
if (isNaN(c2)) c2 = 0;
if (isNaN(c3)) c3 = 0;
if (isNaN(c4)) c4 = 0;
if (isNaN(c5)) c5 = 0;
if (isNaN(c6)) c6 = 0;
if (isNaN(c7)) c7 = 0;
if (isNaN(c8)) c8 = 0;
if (isNaN(c9)) c9 = 0;
if (isNaN(c10)) c10 = 0;
if (isNaN(c11)) c11 = 0;
if (isNaN(c12)) c12 = 0;
var soma = (c1+c2+c3+c4+c5+c6+c7+c8+c9+c10+c11+c12);
document.getElementById("total").value = parseFloat(soma.toFixed(2));
}
</script>
<form action=script.php method=post>
<table border="0"><tr>
<td>
<input type=text id="info" onkeyup="repete();soma();" style='background:#ccc;'><br>
<input type=text id="vl1" onkeyup="soma();"><br>
<input type=text id="vl2" onkeyup="soma();"><br>
<input type=text id="vl3" onkeyup="soma();"><br>
</td>
<td>
<input type=text id="vl4" onkeyup="soma();"><br>
<input type=text id="vl5" onkeyup="soma();"><br>
<input type=text id="vl6" onkeyup="soma();"><br>
<input type=text id="vl7" onkeyup="soma();"><br>
</td>
<td>
<input type=text id="vl8" onkeyup="soma();"><br>
<input type=text id="vl9" onkeyup="soma();"><br>
<input type=text id="vl10" onkeyup="soma();"><br>
<input type=text id="vl11" onkeyup="soma();"><br>
<td></tr><tr><td colspan="2">VALOR TOTAL DO CONTRATO</td>
<td align="right"><input type=text id="total" style='background:#ccc;'>
</td>
</tr></table>
<input type=submit value=gravar>
<input type=reset value=Limpar>
</form>
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.