I have a form that is is loaded through a while from bd. the structure is this:
<form id="formulario" name="formulario" action="javascript:Func()" method="post">
<div id="div_prod">
<?php $sql_prod = mysql_query("SELECT bla bla bla");
while($sql= mysql_fetch_object($sql_prod )) { ; ?>
<input name="a" id="a" type="hidden" value="<?php echo $sql->a; ?>">
<input name="b" id="b" type="hidden" value="<?php echo $sql->b; ?>">
<input name="c" id="c" type="hidden" value="<?php echo $sql->c; ?>">
<button type="submit"><?php echo $sql->a; ?></button> <?php }; ?>
</div>
</form>
Either the name inputs a, b, and c are generated n times, depending on the number of records returned from the select.
So, I have a function that adds the results in mysql, as below.
$("#formulario").submit(function() {
var a = $("#a").val();
var b = $("#b").val();
var c = $("#c").val();
$.post('../scripts/arquivo.php', {a: a, b: b, c: c}, function(resposta){
if (resposta != false) {
$("#status").html(resposta);
} else {
$("#status").html("Inserção realizada com sucesso!");
}
});
The process is working fine, however, it always loads only the first while.
I have tried to put the variables with name and id [] (eg, but it does not send anything and it does not give any error.
Leaving without the [] only sends the first item.
How do I resolve this?