0
Look at the picture;
You notice that the first position of the list is being indicated with the arrow, as I do that every time the form is loaded it load with the first position of the list?
This is my HTML;
<div class="form-group">
<label class="col-sm-2 control-label"><fmt:message key="label.sagresPessoal.tela.prestacao.unidade.jurisdicionada" /></label>
<div class="col-sm-8">
<select id="idUJ" name="prestacaoFolha.idUnidadeGestora" class="form-control select2 ">
<option value ="">-</option>
<c:forEach items="${listPessoaJuridica}" var="PJ">
<option value="${fn:replace(PJ.codigo,'.','')}">${PJ.nome}</option>
</c:forEach>
</select>
</div>
</div>
I tried that way, but it didn’t work!;
$("#idUJ option:first").attr('selected','selected');
Please, how could I do?
I’m using this Javascript;
function justificarRemessa() {
$('#idUJ').val();
alert($('#idUJ').val());
$('#idPeriodoInicio').val("");
$('#idMotivo').val("");
$('#idPeriodoFim').val("");
$('#modalJustificar').modal('show');
}
What component are you using to build the search? By the way... because you need the first
<option value ="">-</option>
?– Leandro Angelo
Did you mean the SECOND item of the list? Because by the code this selected is the first.
– Ronaldo Araújo Alves
It is the first item on the list that is blank!
– wladyband