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>
3
  • 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. Commented Jul 22, 2020 at 21:23
  • Yes i mean selecting the option on the html page. Do you have any reference to this JS? Commented Jul 22, 2020 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 Commented Jul 23, 2020 at 14:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.