Fastadmin二级联动selectpage

<div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Kycms_lang_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-kycms_lang_id" data-rule="required" data-source="kycms/lang/index" class="form-control selectpage" name="row[kycms_lang_id]" type="text" value="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Kycms_prdcate_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-kycms_prdcate_id" data-rule="required" data-source="kycms/prdcate/index" class="form-control selectpage" name="row[kycms_prdcate_id]" type="text" value="">
        </div>
    </div>
$("#c-kycms_lang_id").change(function(){
	$("#c-kycms_prdcate_id").selectPageClear();
	var yiji = $("#c-kycms_lang_id").val();
	$.ajax({
		url: "kycms/product/erji",
		type: 'post',
		dataType: 'json',
		data: {yiji:yiji},
		success: function (res) {
			if (res.code == 1) {
				$('#c-kycms_prdcate_id').selectPageData(res.data);
			}
		}
	});
})
public function erji(){
	$yiji = $this->request->param("yiji");
	$data = Db::name("kycms_prdcate")->where(['status'=>1,'kycms_lang_id'=>$yiji])->select();
	$ret=[];
	foreach($data as $k=>$v){
		$ret[]=['id'=>$v['id'],'name'=>$v['name']];
	}
	$this->success("","",$ret);
}

发表评论