0

I want to add multiple textbox(s) depending on the Id value from a dropdown list. For example, if i select Option1 i need to add two dynamic text box. If i select Option 2, i need to add 5 text boxes.

Thymleaf:

        <div>
        <label>Source Id:</label>
        <select th:field="*{id}">
            <option th:each="p : ${listId}" th:value="${p}" th:text="${p}" />
        </select>
        <span th:if="${#fields.hasErrors('Id')}" th:errors="*{id}">Id error</span>
        </div>
Tarun Pande
  • 371
  • 1
  • 6
  • 18
  • When you saying "if I select Option", you mean you selecting the option on the page, displayed in a browser, am I correct? If so, you would need to write small Javascript to dynamically manipulate with DOM. At this point, Thymeleaf already has done and you are dealing with regular HTML. – Slava Ivanov Jul 22 '20 at 21:23
  • Yes i mean selecting the option on the html page. Do you have any reference to this JS? – Tarun Pande Jul 22 '20 at 22:40
  • This would take a few minutes to write the JS yourself. Plenty of examples can be found on SO as well, something like ... [Dropdown using javascript onchange](https://stackoverflow.com/questions/12080098/dropdown-using-javascript-onchange) – Slava Ivanov Jul 23 '20 at 14:01

0 Answers0