load select option with spring variable

Asked

Viewed 105 times

0

I have a table populated with <c:foreach> and in one of the columns I have a 'CHANGE' click on it and load the information of what I want to change on another page. Already on the other page, the information I wanted to popular my select option according to the information you brought via ID.

EX: in my carregaModal below I bring only 2 things 'Defensive' and 'Aggressive' I wanted to already load with one or the other when page load.

${carregaModal.caracteristica

HTML

<div class="form-group">
    <label>Característica</label>
    <div>
        <select name="caracteristica" class="form-control">
            <option>Defensivo</option>
            <option>Agressivo</option>
        </select>
    </div>
</div>

1 answer

0


Oops, a lot of research and a little understanding, for those who had the same little problem that I follow as I solved.

                                             <select name="quadra" class="form-control">
                                                <option value="Rápida" ${carregaModal.quadra == 'Rápida'? 'selected' : '' }>Rápida</option>
                                                <option value="Saibro" ${carregaModal.quadra == 'Saibro'? 'selected' : '' }>Saibro</option>
                                                <option value="Grama" ${carregaModal.quadra == 'Grama'? 'selected' : '' }>Grama</option>
                                            </select>

if your select is in

                                            <select name="modalidadeTemp" class="form-control">
                                                <c:forEach items="${listaModalidades}" var="listaModalidades">
                                                    <option value="${listaModalidades.nomeModalidadeTemp}" ${listaModalidades.nomeModalidadeTemp == carregaModal.modalidadeTemp ? 'selected' : ''}>${listaModalidades.nomeModalidadeTemp}</option>
                                                </c:forEach>
                                            </select>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.