根据前两个下拉框的值去动态渲染第三个下拉框的值

  • 效果

2022-10-08T06:21:52.png

  • 前端代码

2022-10-08T06:19:58.png

<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Url')}:</label>
<div class="col-xs-12 col-sm-8">
     <input id="c-url" data-rule="required" data-field="url" data-params='{"custom[p_id]":"","custom[r_id]":""}' data-source="website/selectpage" class="form-control selectpage" name="row[url]" type="text" value="">
</div>
</div>
  • JS代码

2022-10-08T06:19:03.png

add: function () {
        // 二级联动查询
        $("#c-url").data("params",function(obj)
        {   
            if( $("#c-project").val() != "" && $("#c-region").val() != "" )
            {
                return {custom: {p_id: $("#c-project").val(), r_id: $("#c-region").val()}};
            }
            else
            {   
                return false;
            };
        });
          $("#c-url").data("format-item", function(row){
            return row.name + " - " + row.url;
        });
        Controller.api.bindevent();
    },