html - How to call url which depends on input in Thymeleaf? -
i have form in thymeleaf in there drop down list , button. want call url when button clicked depends on value of drop down selected. dropdown, serviceid selected , url uses serviceid. how do this?
<form action="#" th:action="@{/heart2heart/format/{serviceid}}" method="get" role="form"> <div class="form-group"> <select th:field="*{serviceid}" class="form-control"> <option th:each="service : ${services}" th:value="${service.id}" th:text="${service.description}">customer service</option> </select> </div> <div class="form-group"> <button type="button" name="addrow" th:text="#{button.download}" class="btn btn-primary btn-md">download</button> </div> </form>
this combination of javascript/jquery , integrating form.
so first need set id's:
<select id="someidyougaveit" th:field="*{serviceid}" class="form-control"> //code </select> <form id="yourform" action="#" th:action="@{/heart2heart/format/{serviceid}}" method="get" role="form"> // code </form> then using javascript change action after obtaining value:
var frm = document.getelementbyid('yourform'); if(frm) { frm.action = 'yoururl'+$("#someidyougaveit").val(); }
Comments
Post a Comment