Colleagues,
I have a system where the customer clicks a button, opens a modal bootstrap for him to register a story. I need to make that when doing the register, the combox where the materials are updated.
I tried the following code:
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" style="background-color: #CF850F; color: #FFF; font-weight: bold">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Cadastrar nova matéria</h4>
</div>
<div class="modal-body">
<div class="form-group">
<form method="post" name="post" id="contact-form">
<div id="success"></div>
<label for="exampleInputEmail1">Matéria:</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-arrow-circle-right" aria-hidden="true"></i>
</div>
<input type="text" class="form-control" name="NovaMateria" maxlength="150" id="novovalor">
</div>
</form>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-warning" data-dismiss="modal" id="submit"><i class="fa fa-floppy-o fa-lg" aria-hidden="true"></i> Salvar</button> <button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
</div>
</div>
</div>
</div>
When I put text field and place the commented code, it works:
<script>
// Atualizar
/* $(function(){
$("#submit").click(function(){
$("#materia").val($("#novovalor").val());
});
});
*/
$(document).ready(function(){
$("#submit").click(function(){
$('#novovalor').change(function(){
$('#materia').load($('#novovalor').val());
});
});
});
</script>
And the combox:
<select name="Materias" class="form-control select2" id="materia" data-placeholder="Selecione a matéria" style="width: 100%;">
............
</select>