1
I am passing the data of some inputs to a modal, I am doing this with jquery, until ai blza, more accurate the data that were sent and use them in a mysqli query, my doubt as I pass the values sent by jquery to php variables and so useswere at my consultation ?
Form:
<form class="form-horizontal" action="data/form_cadastra_devolucao.php" method="POST">
<input type="hidden" id="cliente" name="cliente" value="<?php echo $cliente ; ?>">
<input type="hidden" id="nome" name="nome" value="<?php echo $nome ; ?>">
<div class="comtainer">
<div class="row">
<div class="col-md-6">
<label for="data">Data:</label>
<input type="date" class="form-control" id="data" name="data" required>
</div>
<div class="col-md-6">
<label for="loja">Loja:</label>
<select class="form-control" id="loja" name="loja" required>
<option ></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-md-6">
<label for="pdv">Pdv:</label>
<input type="text" class="form-control" id="pdv" name="pdv" required>
</div>
<div class="col-md-5">
<label for="cupom">Cupom:</label>
<input type="text" class="form-control" id="cupom" name="cupom" required>
</div>
<div class="col-md-1">
<a data-toggle="modal" href="#modalItensCupom">VALIDAR</a>
</div>
</div>
<br>
<label for="motivo">Motivo:</label>
<textarea class="form-control" rows="5" id="motivo" name="motivo"></textarea>
<br>
<button type="submit" class="btn btn-primary" style="float: right;"><span class="glyphicon glyphicon-ok"></span> CADASTRAR</button>
</form>
Modal:
<!-- Modal -->
<div class="modal fade" id="modalItensCupom" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">CUPOM <div id="rcupom"></div></h4>
</div>
<div class="modal-body">
<p id="rdata"></p>
<p id="rloja"></p>
<p id="rpdv"></p>
<p id="rcupom"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
</div>
</div>
</div>
</div>
Jquery:
<script type="text/javascript">
;(function($) {
$('#modalItensCupom').on('show.bs.modal', function() {
var idata = $("#data").val();
var iloja = $("#loja").val();
var ipdv = $("#pdv").val();
var icupom = $("#cupom").val();
$( '#rdata' ).text( idata );
$( '#rloja' ).text( iloja );
$( '#rpdv' ).text( ipdv );
$( '#rcupom' ).text( icupom );
});
}(jQuery));
</script>
With HTTP requests which in this case can be asynchronous via AJAX.
– Woss