Good morning!
I have a question, and I wonder if anyone can help me.
I have two selects
on my page. I have a button to register a new record and another to edit each record.
When I click edit, it opens a modal containing the information for that record. If I then click the "New Master" button, it continues to leave the selects
with the last record information.
Thanks in advance for your help!
Below, the modal code.
<div class="modal fade" id="modal-edit-veiculo" tabindex="-1" role="dialog" aria-labelledby="modal-edit-veiculo-label" aria-hidden="true">
<div class="modal-dialog" style="width:80% !important;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">×</span>
<span class="sr-only">Fechar</span>
</button>
<h4 class="modal-title" id="modal-edit-veiculo-label">Novo Veículo</h4>
</div><!-- modal header -->
<div class="modal-body">
<form class="form-horizontal">
<div class="col-md-6">
<div class="form-group">
<label class="col-sm-4 control-label" for="unidade-veiculo">Unidade</label>
<div class="col-sm-8">
<select class="form-control modal-detalhe-veiculo-unidade-veiculo" name="unidade-veiculo">
<option>Selecione uma Unidade</option>
<option value="001S000000nlKu4IAE">Teste 2</option>
<option value="001S000000nmTBdIAM">Inpulso 04</option>
<option value="001S000000nm2EiIAI">Teste Inpulso 8</option>
<option value="001S000000nm2deIAA">Teste Inpulso 10</option>
<option value="001S000000nm2fGIAQ">Teste Inpulso 14</option>
<option value="001S000000kHf7lIAC">RMR COMERCIO E TRANSPORTE DE GAS LTDA.</option>
<option value="001S000000nJfoyIAC">Santos</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="placa">Placa</label>
<div class="col-sm-8">
<input type="text" class="form-control modal-detalhe-veiculo-placa-veiculo" name="placa" placeholder="Placa"/>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="col-sm-4 control-label" for="tipo-veiculo">Tipo de Veículo</label>
<div class="col-sm-8">
<select class="form-control modal-detalhe-veiculo-tipo-veiculo" name="tipo-veiculo">
<option>Selecione um Tipo de veículo</option>
<option value="a1vS0000000CLYkIAO">Caminhonete</option>
<option value="a1vS0000000CLYpIAO">Triciclo</option>
<option value="a1vS0000000CLYfIAO">Pick-Up</option>
<option value="a1vS0000000CLYuIAO">Caminhão</option>
<option value="a1vS0000000CLYzIAO">Moto</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="descricao-veiculo">Descrição</label>
<div class="col-sm-8">
<input type="text" class="form-control modal-detalhe-veiculo-descricao-veiculo" name="descricao-veiculo" placeholder="Descrição"/>
</div>
</div>
</div>
</form>
<div class="clearfix"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
<button type="button" class="btn btn-primary" data-dismiss="modal" id="btn-salvar-veiculo">Gravar</button>
</div>
</div>
</div>
</div>
Below, the button that opens the modal:
<div class="col-xs-12" style="margin-top: 10px;">
<div class="form-group" style="border: 1px">
<div id="" class="col-xs-12 " align="right">
<button id="btn-novo-veiculo" class="btn btn-primary">Novo Cadastro</button>
</div>
</div>
</div>
the function to clear fields:
function clearModal(){
j$('#modal-edit-veiculo .modal-body input').val('');
}
The inputs
is being cleaned, now I need to position the selects
on index 0 when I click the button.