• 0
Sign in to follow this  
cdfree

incremetar $_POST[vl $i];

Question

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:

&lt;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>

Share this post


Link to post
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.

Sign in to follow this