I'm trying to get a selectbox to be disabled by a checkbox but pass it's selected value to a hidden input beforehand so that the hidden value will be submitted by the form even though it's selected value is disabled in the selectbox input.
The code from the select is below... you can see the checkbox before it and hidden input after. I've tried many ways/hour to do it in the form by reference or by Angularjs ng-change ... the change function is below. Someone out there must have done this, could you please let me know how?
using Thymeleaf, Angularjs ... and Spring boot.
Cheers!
Johnny O.
<form id = "sch" action="#" th:action="@{/search}" th:object="${book}" method="post">
<div ng-controller="orderCtrl">
<label>Distinct String Author</label>
<input type="checkbox" name="ranking1" value="1" ng-model="checkboxSelection1" />
<select th:field="*{author}" ng-model="author" ng-change="change(author);" ng-disabled="checkboxSelection1" >
<option th:each="author: ${authors}"
th:value="${author}"
th:text="${author}">Author</option>
</select>
<input type="hidden" th:field= "*{author}"
ng-model="author" value="{{author}}" ng-disabled="!checkboxSelection1"/>
$scope.change = function(field) {
order = order +"/"+field;
$scope.author = field;
};
Aucun commentaire:
Enregistrer un commentaire