通过复选框将Thymeleaf隐藏输入值设置为禁用所选输入

时间:2015-12-16 07:34:54

标签: angularjs select checkbox hidden thymeleaf

我正在尝试通过复选框禁用选择框,但事先将其选定值传递给隐藏输入,以便即使在selectbox输入中禁用了选定值,表单也会提交隐藏值。

select中的代码如下...你可以看到之前的复选框和之后的隐藏输入。我通过引用或Angularjs ng-change在表单中尝试了很多方式/小时...更改功能如下所示。那里的人肯定已经这样做了,你能告诉我怎么样吗?

使用Thymeleaf,Angularjs ......和Spring boot。

干杯!

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;


      };

0 个答案:

没有答案