1
I’m trying to submit a form contained in modal boostrap, but I don’t know how to perform this action.
Look down at my code:
Pagina Principal:
<div id="idDivModal4" class="modal fade">
<div class="modal-dialog modal-lg">
<div class="modal-content">
</div>
</div>
</div>
<a class="btn btn-block btn-primary top10 btn-sm" href='#idDivModal4' role='button' data-toggle='modal' data-load-remote='atualizar-status/<?php echo $codigo;?>' data-remote-target='#idDivModal4 .modal-content' aria-hidden='true' > Atualizar Status</a>
Page (update-status) containing modal form:
<div class="modal-body">
<select name="campo_status " id="campo_status " class="form-control div-campo-status" required>
<option value="Sim">Sim</option>
<option value="Não">Não</option>
</select>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">Cancelar</button>
<a class="btn-atualizar-status">Atualizar</a>
</div>
On the Home page, include the following jquery:
$('#idDivModal4').on('click', '.btn-atualizar-status', function(){
{
var campo_status = $(this).parent().find('.div-campo-status').val();
alert(campo_status);
});
It happens that it triggers the event click, however, when clicking the button, it shows the variable as "Undefined". How I can redeem the value of the select field?
Any help thanks =D
Hello Lucas, I tested it this way, but it didn’t work. when I click on the button, nothing happens.
– Luis
I used " $('#idDivModal4'). on('click', '.btn-update-status', Function()? " and it worked =D
– Luis