Thymeleaf 实现内部级联的方法

通过下拉选择kid,动态生成row和col的下拉框

<select name="kid" class="chosen-select form-control" id="kid" data-placeholder="请选择..." οnchange="rowcolSel();">
<option>请选择...option>
<option th:each="k:${Kitchen}" th:value="${k.id}" th:text="${k.name}" th:attr="row=${k.row},col=${k.col}">option>

select>

js方法:
function rowcolSel() {
          $("#row").html("");
          $("#col").html("");
   var row=$("#kid option:selected").attr("row");
          for (i=1;i<=row;i++)
   {
              $("#row").append("+i+"");
   }
   var col=$("#kid option:selected").attr("col");
   for (i=1;i<=col;i++)
   {
              $("#col").append("+i+"");
   }
}

你可能感兴趣的:(技术)