1
I have this code to confirm a form in a Bootstrap modal.
How do I get the name you selected in the select of the print form in the bootstrap confimation modal?
$('#submitBtn').click(function() {
/* when the button in the form, display the entered values in the modal */
$('#cliente').text($('#cliente').val());
});
$('#submitBtn').click(function() {
$('#cliente').text($('#cliente').val());
});
$('#submit').click(function(){
$('#formfield').submit();
});
Form
<form role="form" name="form1" method="post" id="formfield" action="cadastrar_DADOS_arquivos_enviar.php" enctype="multipart/form-data" accept-charset="UTF-8">
<div class="clear"></div>
<br>
<div class="col-md-12">
<label>Nome</label>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user" aria-hidden="true"></i></span>
<select id="cliente" name="cliente" class="form-control">
<option value="541">
2LJM SERVICOS ADMINISTRATIVOS LTDA
</option>
</select>
</div>
</div>
<div class="clear"></div>
<div class="col-md-12">
<label>Editar o nome</label>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user" aria-hidden="true"></i></span>
<select id="categoria" name="categoria" class="form-control">
<option value="30">
contabilidade
</option>
<option value="33">
financeiro
</option>
<option value="31">
fiscal
</option>
<option value="34">
outras
</option>
<option value="32">
setor pessoal
</option>
</select>
</div>
</div>
<div class="clear"></div>
<div class="col-md-12">
<label>Arquivos</label>
<div id="photoWrapper">
<label>
<input type="file" name="upload[]" multiple="multiple">
<div class="newInputWrapper">
<!-- custom picture -->
<span id="photo"></span>
<!-- custom text -->
<p class="filename">C:\fakepath\boleto-dominio.pdf</p>
</div>
</label>
</div>
</div>
<div class="clear"></div>
<div class="form-group" style="text-align: center;">
<input type="button" name="cadastrar_arquivos" value="Enviar" id="cadastrar_arquivos submitBtn submit" data-toggle="modal" data-target="#confirm-submit" class=" btn btn-success dropdown-toggle btn-lg text-center">
</div>
<div class="modal fade" id="confirm-submit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
Confirmação de envio de arquvos
</div>
<div class="modal-body">
Tem certeza que deseja enviar para o cliente?
<!-- We display the details entered by the user here -->
<table class="table">
<tbody>
<tr>
<th>Last Name</th>
<td id="cliente"></td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
<a href="#" id="submit" class="btn btn-success success">Submit</a>
</div>
</div>
</div>
</div>
</form>
Your HTML has two elements with the same ID
cliente, cannot have two elements with the same ID in HTML and the ID should be only one parameter, you have putid="cadastrar_arquivos submitBtn submit", after fixing this put a different id in the modal and change to appeartext()and notval().– Laércio Lopes
can show that you spoke in practice by modifying my codes?
– Wagner
It’s in my answer.
– Laércio Lopes
is printing all options and not only the selected
– Wagner