禁用mvc中除选定项目以外的所有项目 [英] Disable all items from the except selected item in mvc

查看:89
本文介绍了禁用mvc中除选定项目以外的所有项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的视图中有5个jquery buttonset复选框

Hi all,

I have 5 jquery buttonset checkbox in my view

<div id="format">
                <input type="checkbox" id="check2" onClick="disableButtons(id);"/><label for="check2">Check2</label>
                <input type="checkbox" id="check3" onClick="disableButtons(id);" /><label for="check3">Check3</label>
                <input type="checkbox" id="check4" onClick="disableButtons(id);"/><label for="check4">Check4</label>
                <input type="checkbox" id="check5" onClick="disableButtons(id);"/><label for="check5">Check5</label>
                <input type="checkbox" id="check6" onClick="disableButtons(id);"/><label for="check6">Check6</label>
</div>


我的Javascript代码是


and my Javascript code is

<script type="text/javascript">
    $(function () {
        $("#dynamicColumns,#format").buttonset();
    });

    function diableButtons(id) {
        //        alert(id.toString() + " Welcome");
        if (id == ''check2'') {
            $(''#check3'').attr("disabled", true).button(''refresh'');
            $(''#check4'').attr("disabled", true).button(''refresh'');
            $(''#check5'').attr("disabled", true).button(''refresh'');
            $(''#check6'').attr("disabled", true).button(''refresh'');
        }
        if (id == ''check3'') {
            $(''#check2'').attr("disabled", true).button(''refresh'');
            $(''#check4'').attr("disabled", true).button(''refresh'');
            $(''#check5'').attr("disabled", true).button(''refresh'');
            $(''#check6'').attr("disabled", true).button(''refresh'');
        }
       }
</script>


上面的代码很好用,但是如果我检查每个id都不会很好看.
是否有任何优化选项可以验证条件?
当我取消选中按钮集复选框时,其他按钮集应重置为其默认状态.

例如:
如果我选择Check2按钮集,则应禁用其他检查按钮集(check3,check4,check5,check6).
如果我取消选择check2按钮集,则应启用其他检查按钮集(check3,check4,check5,check6).
其他检查按钮集也是如此.
请尽快帮助我.
预先感谢.


The above code works fine, but it wont look good if i check for every id.
Is there any optimize option to validate the condition?
When i uncheck the buttonset checkbox, other buttonset should reset to its default state.

For example:
If i select Check2 buttonset, other check buttonset(check3,check4,check5,check6) should be disabled.
And if i deselect check2 buttonset, other check buttonset(check3,check4,check5,check6) should be enabled.
Similarly for other check buttonsets too.
Please help me ASAP.
Thanks in advance.

推荐答案

(function(){
(function () {


(#dynamicColumns,#format").buttonset() ; }); 函数diableButtons(id){ //alert(id.toString()+"Welcome"); if(id ==``check2''){
("#dynamicColumns,#format").buttonset(); }); function diableButtons(id) { // alert(id.toString() + " Welcome"); if (id == ''check2'') {


(``#check3'').attr("disabled",true).button(''refresh'');
(''#check3'').attr("disabled", true).button(''refresh'');


这篇关于禁用mvc中除选定项目以外的所有项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆