Dear colleagues.
I want to pass the values from the mysql database to the bootstrap modal and after a few searches, I found the code below:
<a href='#myModal' data-id-pergunta='<?php echo $jm->IdCodFotos; ?>' type="button" class="btn btn-success" data-toggle="modal" title="Alterar sua foto">Alterar</a>
JavaScript:
$('#myModal').on('show.bs.modal', function(e) {
var idPergunta = $(e.relatedTarget).data('id-pergunta');
$(e.currentTarget).find('input[name="perguntaId"]').val(idPergunta);
});
Modal:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Alterar Foto</h4>
</div>
<div class="modal-body">
<input type="text" id="perguntaId" name="perguntaId" class="form-control" value="">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
But unfortunately it's not working!