六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 158|回复: 0

在js中获取checkbox是否被选中 或者其值

[复制链接]

升级  17.33%

18

主题

18

主题

18

主题

秀才

Rank: 2

积分
76
 楼主| 发表于 2013-2-7 23:42:42 | 显示全部楼层 |阅读模式
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="";
}

}




}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表