一段关于父子功能checkbox选择的javascript
function subFunctionState(chkid, state) {
var chkcount = document.form1.functionID.length;
for (var i = 0; i < chkcount; i++) {
var subFun = document.form1.functionID[i];
var subFunID = subFun.id;
var subFun_parentID = subFunID.substr(0, subFunID.indexOf("|"));
if (chkid == subFun_parentID) {
subFun.checked = state;
}
}
}
function subFunctionCheck(chkid) {
var parentFun = document.getElementById(chkid);
if (parentFun.checked) {
subFunctionState(chkid, true);
} else {
subFunctionState(chkid, false);
}
}
function getBrotherState(chkid) {
var chkcount = document.form1.functionID.length;
for (var i = 0; i < chkcount; i++) {
var subFun = document.form1.functionID[i];
var subFunID = subFun.id;
var subFun_parentID = subFunID.substr(0, subFunID.indexOf("|"));
if (chkid == subFun_parentID&&subFun.checked) {
return true;
}
}
return false;
}
function parentFunctionCheck(chkid){
var subFun = document.getElementById(chkid);
var parentID =chkid.substr(0,chkid.indexOf("|"));
var parentFun = document.getElementById(parentID);
if(subFun.checked||getBrotherState(parentID)){
parentFun.checked=true;
}else{
parentFun.checked=false;
}
}
function rightChoose() {
var unchooseRole = document.getElementById("unchooseRole");
var chooseRole = document.getElementById("chooseRole");
if (unchooseRole.options.selectedIndex != -1) {
chooseRole.options[chooseRole.length] =
new Option(unchooseRole.options[unchooseRole.selectedIndex].text,unchooseRole.options[unchooseRole.selectedIndex].value );
unchooseRole.options.remove(unchooseRole.options.selectedIndex);
}else{
alert("请选定要为此用户分配的角色");
}
}
function leftChoose(){
var unchooseRole = document.getElementById("unchooseRole");
var chooseRole = document.getElementById("chooseRole");
if (chooseRole.options.selectedIndex != -1) {
unchooseRole.options[unchooseRole.length] =
new Option(chooseRole.options[chooseRole.selectedIndex].text,chooseRole.options[chooseRole.selectedIndex].value);
chooseRole.options.remove(chooseRole.options.selectedIndex);
}else{
alert("请选定要取消分配给此用户的角色");
}
}
- 19:54
- 浏览 (40)
- 评论 (0)
- 分类: JAVASCRIPT随笔
- 相关推荐
发表评论
- 浏览: 2542 次
- 性别:

- 来自: 长春

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
websphere默名奇妙宕机的 ...
找到解决方案了么?我的系统也存在这个问题?
-- by supersrc -
java传参是以传值的方式而 ...
似乎你的理解不对,参数还是传址。只是在这里你的testObj已经不是指向原来对象 ...
-- by joachimz -
websphere默名奇妙宕机的 ...
以为你解决了,最后还是没解决! 把格式排版搞好哦,标题也写清楚
-- by xiaoyunly -
将听吾计用之必胜留之,将 ...
打游戏? 工作时间? 是否有分派任务给他? 是不是他做完了? 是不是没事还要装得 ...
-- by xqstation -
将听吾计用之必胜留之,将 ...
感觉楼主,只适合带童子军,你这样的管理方式,只适合管理那些刚毕业的学生。 好的团 ...
-- by msf_job






评论排行榜