1
I have a table with data and one of the fields has 1 edit button. What I want is that, when clicking, it opens me a modal with all filled data of the respective line that I clicked. I already managed to do that, but it wasn’t with a modal, it was with a separate file, and now I wanted it in a modal. I wonder if you could help me?
Modal code
<div class="modal fade" id="large-Modal1" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title text-center text-primary"><i class="fa fa-user-plus"></i> Alterar Cliente</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<form id="edit_equipa" method="POST" action="clientes.php?edit=1" enctype="multipart/form-data">
<div class="modal-body">
<input type="hidden" name="action" value="executeEdit">
<input type="hidden" class="" name="alterar_cliente_id" id="alterar_cliente_id" value="<?php echo $row['cliente_id']; ?>">
<div class="form-group form-float col-lg-12">
<label><strong>ID Cliente</strong></label>
<div class="form-line">
<input type="text" class="form-control" disabled required ><?php echo $row['cliente_id']; ?></input>
</div>
</div>
<div class="form-group form-float col-lg-12">
<label><strong>Nome</strong></label>
<div class="form-line">
<input type="text" class="form-control" name="alterar_nome" id="alterar_nome" value="<?php echo $row['nome'];?>" required >
</div>
</div>
</td>
<div class="form-group form-float col-lg-12">
<label><strong>Morada</strong></label>
<div class="form-line">
<textarea class="form-control" name="alterar_morada" id="alterar_morada" required ><?php echo $row['morada'];?></textarea>
<!--<label class="form-label">Data</label>-->
</div>
</div>
<div class="form-group form-float col-lg-12">
<label><strong>Telefone</strong></label>
<div class="form-line">
<input type="text" class="form-control" name="alterar_telefone" id="alterar_telefone" value="<?php echo $row['telefone'];?>" required >
<!--<label class="form-label">Data</label>-->
</div>
</div>
</td>
<div class="form-group form-float col-lg-12">
<label><strong>Email</strong></label>
<div class="form-line">
<input type="text" class="form-control" name="alterar_email" id="alterar_email" value="<?php echo $row['email'];?>" required >
<!--<label class="form-label">Data</label>-->
</div>
</div>
<div class="form-group form-float col-lg-12">
<label><strong>Contribuinte</strong></label>
<div class="form-line">
<input type="text" class="form-control" name="alterar_contribuinte" id="alterar_contribuinte" value="<?php echo $row['contribuinte'];?>" required >
<!--<label class="form-label">Data</label>-->
</div>
</div>
<div class="form-group form-float col-lg-12">
<label><strong>Horas</strong></label>
<div class="form-line">
<input type="time" class="form-control" name="alterar_horas" id="alterar_horas" value="<?php echo $row['horas'];?>" required >
<!--<label class="form-label">Data</label>-->
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default waves-effect " data-dismiss="modal">Fechar</button>
<button type="submit" class="btn btn-primary waves-effect waves-light" id="btn_inserir">Alterar</button>
</div>
</form>
Code of the table button
<td style="vertical-align: middle;">
<div>
<a id="btn_editar?<?php echo $row['cliente_id']; ?>" href="#div_editar" class="btn btn-info btn-xs waves-effect" data-toggle="modal" data-target="#large-Modal1">
<i class="fa fa-lg fa-edit"></i><!--edit-->
</a>
<a href="#" onclick="if (confirm('Tem a certeza que deseja eliminar este Cliente?')) window.location='iframes/clientes_apagar.php?cliente_id=<?php echo $row['cliente_id']; ?>';return false" class="btn btn-danger btn-xs waves-effect">
<i class="fa fa-lg fa-trash"></i><!--delete-->
</a>
</div>
</td>
It’s also a good alternative and it might come in handy in the future thanks for the time and help!!
– Shider
Oops! Needing we are there! D
– user98628
Thank you very much, there is no better choice than Stackoverflow ahah !!
– Shider