admin管理员组文章数量:1023744
I have a list of objects services
in my thymeleaf context, and I have the following at my page:
<select id="inputService" name="idService" size="1">
<option th:each="service : ${services}" th:text="${service.name}" th:value="${service.idService}"/>
</select>
<p id="selectedServiceLimits"></p>
Each object from services
contains fields minAmount
and maxAmount
. How can I print into my p
element the these two fields of the selected service
in select
by javascript? And how can I print these two fields of the option that is selected when document is ready?
Thanks!
I have a list of objects services
in my thymeleaf context, and I have the following at my page:
<select id="inputService" name="idService" size="1">
<option th:each="service : ${services}" th:text="${service.name}" th:value="${service.idService}"/>
</select>
<p id="selectedServiceLimits"></p>
Each object from services
contains fields minAmount
and maxAmount
. How can I print into my p
element the these two fields of the selected service
in select
by javascript? And how can I print these two fields of the option that is selected when document is ready?
Thanks!
Share Improve this question asked May 31, 2015 at 10:13 another-programmeranother-programmer 8611 gold badge15 silver badges37 bronze badges1 Answer
Reset to default 2<script th:inline="javascript">
/*<![CDATA[*/
function showLimits() {
var services = /*[[${services}]]*/ null;
var selectedIndex = $("#inputService option:selected").index();
var service = services[selectedIndex];
$("#amountLimits").text("Мин. сумма: " + service.amountMin + ", макс. сумма: " + service.amountMax);
}
$(function() { showLimits(); });
/*]]>*/
</script>
<select id="inputService" name="idService" size="1" onChange="showLimits()">
That's the solution
I have a list of objects services
in my thymeleaf context, and I have the following at my page:
<select id="inputService" name="idService" size="1">
<option th:each="service : ${services}" th:text="${service.name}" th:value="${service.idService}"/>
</select>
<p id="selectedServiceLimits"></p>
Each object from services
contains fields minAmount
and maxAmount
. How can I print into my p
element the these two fields of the selected service
in select
by javascript? And how can I print these two fields of the option that is selected when document is ready?
Thanks!
I have a list of objects services
in my thymeleaf context, and I have the following at my page:
<select id="inputService" name="idService" size="1">
<option th:each="service : ${services}" th:text="${service.name}" th:value="${service.idService}"/>
</select>
<p id="selectedServiceLimits"></p>
Each object from services
contains fields minAmount
and maxAmount
. How can I print into my p
element the these two fields of the selected service
in select
by javascript? And how can I print these two fields of the option that is selected when document is ready?
Thanks!
Share Improve this question asked May 31, 2015 at 10:13 another-programmeranother-programmer 8611 gold badge15 silver badges37 bronze badges1 Answer
Reset to default 2<script th:inline="javascript">
/*<![CDATA[*/
function showLimits() {
var services = /*[[${services}]]*/ null;
var selectedIndex = $("#inputService option:selected").index();
var service = services[selectedIndex];
$("#amountLimits").text("Мин. сумма: " + service.amountMin + ", макс. сумма: " + service.amountMax);
}
$(function() { showLimits(); });
/*]]>*/
</script>
<select id="inputService" name="idService" size="1" onChange="showLimits()">
That's the solution
本文标签: javaJavaScriptThymeleafselect onchangeStack Overflow
版权声明:本文标题:java - JavaScript + Thymeleaf - select onchange - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745597973a2158284.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论