0
I want to take the table id and load a modal with the data. It’s a.php courses page that takes the data from the database, but doesn’t display all the fields, I created a button that by clicking it opens in modal form more details of the course, and the page that contains php is the loadmodal.php You’re not opening the modal to load the data, how can I do it? That’s the code I’ve done so far...
<h4>Lista de cusos</h4>
<table cellpadding="0" cellspacing="0" width="100%" class="table table-hover">
<thead>
<tr>
<th width="15%">Área</th>
<th width="20%">Curso</th>
<th width="20%">Período</th>
<th width="25%">Horário</th>
<th width="5%">CH </th>
<th width="8%">Valor</th>
<th width="1%"></th>
<th width="10%"></th>
</tr>
</thead>
<tbody>
<?php
if($q>0){
while($pegar=mysql_fetch_assoc($busca)){
echo'<tr>';
echo utf8_encode('<td class="esq">'.$pegar['area'].'</td>');
echo utf8_encode('<td class="esq">'.$pegar['curso'].'</td>');
echo utf8_encode('<td class="esq">'.$pegar['dtinicio'].' a '.$pegar['dtfim'].'</td>');
echo utf8_encode('<td class="esq">'.$pegar['horario'].'</td>');
echo utf8_encode('<td class="esq">'.$pegar['ch'].'</td>');
echo utf8_encode('<td class="esq">'.$pegar['investimento'].'</td>');
echo'<td> <a href="loadmodal.php?id='.$pegar['id'].'" data-toggle="meumodal" data-target="#myModalLabel" class="link-target" role="link" aria-expanded="false" aria-controls="modalContainer" style="text-decoration: none; color: black;">
<img src=imgs/plus.png alt=Cadastrar width=20 height=20 border=0 lowsrc=Detalhes title=Detalhes /> </td>';
echo'<td><a href="inscricao/cadastra.php?id='.$pegar['id'].'"> <button id="btn-signup" type="submit" class="btn btn-info" >Inscreva-se</button></a></td>';
echo'</tr>';
}
}
else{
echo"Nenhum Registro Encontrado";
}
?>
</tbody>
</table>
<div class="modal fade" id="modalContainer" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg">
<div class="modal-content"></div>
</div>
</div>
<script type="text/javascript">
$(document).on('click', "[data-toggle='meumodal']", function(event){
event.preventDefault();
target = $(this).attr("data-target");
content = $(this).attr("href");
$(target+".modal .modal-content").load(content,function(){
$(target).modal('show');
});
});
</script>
loadmodal.php
<!-- Modal -->
<div class="modal-header">
<h3 class="modal-title" id="myModalLabel">Cursos</h3>
</div>
<div class="modal-body">
<table cellpadding="0" cellspacing="0" width="100%" class="table table-hover">
<thead>
<tr>
<th width="15%">Área</th>
<th width="20%">Curso</th>
<th width="20%">Período</th>
<th width="25%">Horário</th>
<th width="5%">CH </th>
<th width="6%">Valor</th>
<th width="1%"></th>
<th width="10%"></th>
</tr>
</thead>
<tbody>
<?php
echo'<tr>';
echo utf8_encode('<td class="esq">'.$dados['area'].'</td>');
echo utf8_encode('<td class="esq">'.$dados['curso'].'</td>');
echo utf8_encode('<td class="esq">'.$dados['dtinicio'].' a '.$dados['dtfim'].'</td>');
echo utf8_encode('<td class="esq">'.$dados['horario'].'</td>');
echo utf8_encode('<td class="esq">'.$dados['ch'].'</td>');
echo utf8_encode('<td class="esq">'.$dados['investimento'].'</td>');
echo'</tr>';
?>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
@Kaduamaral saw in your post and I’m adapting...
– VitorCaldeira
Welcome to the sopt. First, it would be interesting for you to explain what you’re doing and what you intend to do with the code, and where it’s not working. Just playing the code doesn’t help you understand the problem. Click [Edit] and supplement the question with these guidelines.
– user28595
If this question is a reference to another, it is also interesting to add the link to the other question in this.
– user28595
I found this answer, but I’m not finding my error... http://answall.com/questions/80035/passar-varialvel-para-modal
– VitorCaldeira
Take a look here.
– Ivan Ferrer