<script> window.onload = function () { //获取checkbox var ids1 = document.getElementsByName(‘VoteOption1‘); //获取值 var choose1 = document.getElementById(‘ctl00_ContentPlaceHolder1_Facilities_864‘).value.split(‘,‘); for (var i = 0; i < ids1.length; i++) { if (contains(choose1, ids1[i].value)) { ids1[i].checked = true; } } } //a:值 //obj:checkbox function contains(a, obj) { var i = a.length; while (i--) { if (a[i] === obj) { return true; } } return false; } </script>
时间: 2024-10-11 05:29:58