I have loop
where I show the user the result of a query, every query of this 3 variáveis
that I need to send to php, what I'm trying to do is send to php the variables that correspond to the clicked button, see the image:
WhatItriedtodowassendingallthevariablesoftheform,butasitisastatuschangeIneedtobesentonlytheregistryvariablestobechanged.
WhatIhavetoscript:
$(function(){$("#frmBusca").validate({
submitHandler: function(form) {
var IdOrdem = $("#IdOrdem");
var IdUnicoop = $("#IdUnicoop");
var Data = $("#Data");
data: "IdOrdem=IdOrdem&IdUnicoop=IdUnicoop&Data=Data";
console.log(data);
return false;
$.ajax({
type: 'POST',
url: 'pUpOrdemPagamento.php',
data: data,
dataType: 'json',
beforeSend: function () {
$("#msgOrdem").html('<div class="alert alert-info fade in"><button class="close" data-dismiss="alert">×</button><i class="fa-fw fa fa-times"></i><strong>AVISO!</strong> Enviando...</div>');
},
success: function (response) {
if (response.codigo == "1") {
$("#msgOrdem").html('<div class="alert alert-success fade in"><button class="close" data-dismiss="alert">×</button><i class="fa-fw fa fa-times"></i><strong>AVISO!</strong>' + response.mensagem + '</div>');
window.setTimeout('location.reload()', 3000);
} else {
$("#msgOrdem").html('<div class="alert alert-danger fade in"><button class="close" data-dismiss="alert">×</button><i class="fa-fw fa fa-times"></i><strong>ATENÇÃO!</strong> ' + response.mensagem + '</div>');
}
$('#frmBusca').each (function(){
this.reset();
});
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr, ajaxOptions, thrownError);
$("#msgOrdem").html('<div class="alert alert-danger fade in"><button class="close" data-dismiss="alert">×</button><i class="fa-fw fa fa-times"></i><strong>ATENÇÃO!</strong> Ocorreu um erro ao tentar enviar a pergunta. Contate o suporte técnico.</div>');
}
});
}
});
});
My table is inside a foreach and so is the fields and form are in hidden inputs.
<table class="table table-bordered table-condensed">
<tbody>
<tr>
<td width="161"><strong>Produto</strong></td>
<td><?php echo $Retorno->Produto; ?></td>
</tr>
<tr>
<td><strong>Safra</strong></td>
<td><?php echo $Retorno->Safra; ?></td>
</tr>
<tr>
<td><strong>Peso</strong></td>
<td><?php echo $Retorno->Peso; ?></td>
</tr>
<tr>
<td><strong>Valor</strong></td>
<td><?php echo $Retorno->Valor; ?></td>
</tr>
</tbody>
<?php if ( $Financiamento == 1 ) { ?>
<tbody>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><strong>Financiamento</strong></td>
</tr>
<tr>
<td><strong>Banco</strong></td>
<td align="left"><?php echo $Retorno->BancoFinanciamento; ?></td>
</tr>
<tr>
<td><strong>Observação</strong></td>
<td align="left"><?php echo $Retorno->Observacao; ?></td>
</tr>
</tbody>
<?php } ?>
<?php if ( $OrdemDeposito == 1 ) { ?>
<tbody>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><strong>Ordem de Depósito</strong></td>
</tr>
<tr>
<td><strong>Banco</strong></td>
<td align="left"><?php echo $Retorno->Banco; ?></td>
</tr>
<tr>
<td><strong>Agência</strong></td>
<td align="left"><?php echo $Retorno->Agencia; ?></td>
</tr>
<tr>
<td><strong>Conta Corrente</strong></td>
<td align="left"><?php echo $Retorno->ContaCorrente; ?></td>
</tr>
<tr>
<td><strong>Correntista</strong></td>
<td align="left"><?php echo $Retorno->Correntista; ?></td>
</tr>
<tr>
<td><strong>CPF CNPJ</strong></td>
<td align="left"><?php echo $Retorno->CPFCNPJ; ?></td>
</tr>
<tr>
<td><strong>Observação</strong></td>
<td align="left"><?php echo $Retorno->ObservacaoDeposito; ?></td>
</tr>
</tbody>
<?php } ?>
<tr>
<td colspan="2" align="right"><button class="btn btn-primary btn-sm">Lido</button></td>
</tr>
<input name="IdOrdem" id="IdOrdem" type="hidden" value="<?php echo $Retorno->IdOrdem; ?>" />
<input name="IdUnicoop" id="IdUnicoop" type="hidden" value="<?php echo $IdUnicoop; ?>" />
<input name="Data" id="Data" type="hidden" value="<?php echo $Retorno->Data; ?>" />
</table>