4
Personal I have a code with a modal that contains a Bootstrap popover
and I would like this information balloon to contain the data of these inputs.
Currently I can already get the data of the variables of php
and move to javascript and when the modal is opened I can view this data in the fields.
In the popover
I can’t do the same.
Follows the code:
$(function () { $(".glyphicon-search").click(function () {
var id_codigo = $(this).data('codigo');
var id_nome = $(this).data('nome');
var id_endereco = $(this).data('endereco');
$(".modal-body #id_codigo").val(id_codigo);
$(".modal-body #id_nome").val(id_nome);
$(".modal-body #id_endereco").val(id_endereco);
})
})
$(document).ready(function(){
$('[data-toggle="popover"]').popover({html: true});
});
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<?php
$codigo = 1;
$nome = "Zé";
$endereco = "Rua";
?>
<br>
<br>
<br>
<br>
<div class="container">
<button type="button" class="btn btn-primary" data-toggle='modal' data-target='#Alt'
data-codigo='$codigo'
data-situacao='$nome'
data-distribuidora='$endereco'
>MODAL</button>
</div>
<!-- Modal -->
<div class="modal fade" id="Alt" 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>
</div>
<div class="modal-body">
<p>
<input readonly id='id_codigo' type='text'><br><br>
<input readonly id='id_nome' type='text'><br><br>
<input readonly id='id_endereco' type='text'><br><br>
<button
id='id_button' type="button" class="btn btn-info" data-position="top-left" title="Contato"
data-toggle="popover"
data-placement="down" data-content="Nome: <input readonly id='id_nome' style='Border:0' type='text'>
<br>Endereço:<input readonly readonly id='id_nome' style='Border:0' type='text'>
<br>Contato:<input readonly readonly id='id_endereco' style='Border:0' type='text'>">Contato</button></p>
</div>
</div>
</div>
</div>
Oops. Great I’m almost there. I would like these variables " Let valor1" to have the same id value that are contained in the inputs. How do I?
– Carlos
In the same way that is populating the modal inputs can popular the Popover, only that the values have to be within variables type
let id_nome = valordoPHP
and in the Popover input you put ${id_name}.– LeAndrade