0
I have a table in which the loader value inside it through PHP needs to be in the value of some inputs that are in a modal boostrap window. I’ve tried several solutions, but they don’t work. When I click on the table row, it loads the modal, but the field is empty. I intend to do so, using the table line to load the modal, and not a button to load the modal. follows the code: HTML table
<tr data-toggle="modal" data-target="#modal_editar_veiculo">
<td id="teste"><?php echo $linha['PLACA'] ?></td>
<td><?php echo $linha['NOME'] ?></td>
<td><?php echo $linha['ANO'] ?></td>
<td><?php echo $linha['CPF'] ?></td>
</tr>
Modal window:
<!-- Modal editar cadastro veículo -->
<div class="modal fade bd-example-modal-lg" id="modal_editar_veiculo" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Alterar dados do veículo</h5>
</div>
<div class="modal-body">
<form class="modal_novo_item">
<div class="row">
<div class="col-md-12">
<input type="text" placeholder="Nome" id="nome" name="nome">
</div>
</div>
<div class="row">
<div class="col-md-12">
<input type="text" placeholder="Ano" id="ano" name="ano">
</div>
</div>
<div class="row">
<div class="col-md-12">
<input type="text" placeholder="Placa" id="placa" name="placa">
</div>
</div>
<div class="row">
<div class="col-md-12">
<select name="proprietario">
<?php listar_editar( $link ); ?>
</select>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Fechar janela</button>
<button type="button" class="btn btn-primary">Alterar</button>
<button type="button" class="btn btn-danger">Excluir</button>
</div>
</div>
</div>
</div>
The window is open, but it doesn’t work. In another project I had already done this, with another jQuery code, however, what loaded the modal was a button. I tried to fit my code, but nothing. Grateful from now on.
Jquery that should be working:
<!--Open modal for editions -->
<script type="text/javascript">
$(document).ready(function (){
var valorDaDiv = $("#teste").text();
$("#placa").val(valorDaDiv);
};
</script>
What is the html of the table?
– Sam
And version of bootstrap?
– Sam
The first item is the table row, on which I want to click, and open the modal. Want to see the whole table?
– Igor
Bootstrap 4.0.0
– Igor
it would be good because here it worked normal.
– Sam
There must be something else going on
– Sam
With those codes I sent? I don’t think
– Igor
Boy, you can edit the question by putting the used libraries?
– user60252