在js中获取checkbox是否被选中 或者其值
function validateUsreId(PKCheckBoxName) {
var checked = false;
var v = document.getElementsByName(PKCheckBoxName);
for (i = 0; i < v.length; i++) {
if (v[i].checked) {
checked = true;
break;
}
}
if (checked == false) {
alert("请选择收件人!");
return false;
}
return true;
}
//参数; PKCheckBoxName 列表中checkbox的name;
function addUsreId(PKCheckBoxName) {
var v = document.getElementsByName(PKCheckBoxName);
var userIds = "";
for (i = 0; i < v.length; i++) {
if (v[i].checked) {
if (userIds != null && userIds != "") {
userIds = userIds+"," + v[i].value;
} else {
userIds = userIds+v[i].value;
}
}
}
$("[name=outboxTo.userIds]").val(userIds);
<input type="checkbox" name="informationTo.sendGroupType" id="sendGroupType" value="0"
onclick='isShowButton(event);'
/>
function isShowButton(evt){
var obj = evt.srcElement || evt.target;
if(obj.checked){
$("#imgSearch").removeAttr("onclick").css("filter", "gray");
$("#imgClear").removeAttr("onclick").css("filter", "gray");
document.getElementById("customerNo").disabled="true";
}
if(!obj.checked){
$("#imgSearch").removeAttr("onclick").css("filter", "");
$("#imgClear").removeAttr("onclick").css("filter", "");
document.getElementById("customerNo").disabled="";
}
}
}