1

I am trying to modify the option in Thymeleaf so that the table can show me only selected item, after clicking the option. Here is my code:

 <th>
 <select th:onchange="???" id="stateSelect" class="form-control" th:field="*{receiverType}">
       <option th:value='NULL'>All aggregators</option>
       <option th:each="receiverType : ${receiverTypes}"
               th:value="${receiverType}"
               th:text="${receiverType}">
       </option>
    </select>
</th>

I know that i should use onchange , but i am confused.

Ratul Sharker
  • 7,484
  • 4
  • 35
  • 44
FeliksB
  • 15
  • 3
  • I think, if you use `onChange` then you have to use JavaScript to toggle/control the `` list. Thymeleaf can do this only if you re-render the HTML via server for every `Change` that is responsible for affecting the `` list. In short, `onChange` looks useless to me, if not rendering via server. – miiiii Apr 04 '22 at 05:12
  • So for example which JS function should i use? – FeliksB Apr 04 '22 at 05:25
  • 1
    That depends on what condition you want to filter the list. And its way of handling in pure JS is quite dirty too. – miiiii Apr 04 '22 at 05:27

0 Answers0