Home >Web Front-end >Layui Tutorial >How to backfill the value selected in layui drop-down

How to backfill the value selected in layui drop-down

angryTom
angryTomOriginal
2019-07-29 17:01:303111browse

How to backfill the value selected in layui drop-down

If you want to know more about layui, you can click: layui tutorial

##layui gets the value in the check box and backfills

layui gets the value in the check box (get multiple, separated by commas)

let  zxbm= document.getElementsByName("zxbm");
		    let check_val = [];
		    for(k in zxbm){
		        if(zxbm[k].checked)
		            check_val.push(zxbm[k].value);
		    }
		   let zxbmcheck=check_val.join(",");

layui checkbox backfill

  var apv = res.data.zxyj.split(","); //将数据以,(逗号)分割形成数组(res.data.zxyj是从后台获取到的数据(形如:1,2,3))
				$("[name=zxbm1]:checkbox").prop("checked", false); 
				if(apv != "") {
					for(var i = 0; i < apv.length; i++) {
						$("[name=zxbm1][value=" + apv[i] + "]").prop("checked", true);
					}
				}

The above is the detailed content of How to backfill the value selected in layui drop-down. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Why layui is goodNext article:Why layui is good