Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery复选框multiselect和row select_Jquery_Asp.net_Web Services - Fatal编程技术网

jQuery复选框multiselect和row select

jQuery复选框multiselect和row select,jquery,asp.net,web-services,Jquery,Asp.net,Web Services,请参阅下面的代码和屏幕。这是一个配置屏幕 单击Fieldname复选框时,它将选中所有复选框,如果我们删除复选框,它将取消选中所有复选框 同时单击Field1复选框。子控件将类似于选择(添加、编辑、删除),如果我们删除复选框,它将取消选中复选框 我的问题是如何进行此操作以及如何获取值 我正在使用jQuery进行此操作 所有的值都是数据库的动态字段 字段名 添加 编辑 删去 字段1 字段2 $(文档).ready(函数(){ $(“表tr:first input[type=checkbox

请参阅下面的代码和屏幕。这是一个配置屏幕

  • 单击Fieldname复选框时,它将选中所有复选框,如果我们删除复选框,它将取消选中所有复选框
  • 同时单击Field1复选框。子控件将类似于选择(添加、编辑、删除),如果我们删除复选框,它将取消选中复选框
  • 我的问题是如何进行此操作以及如何获取值
  • 我正在使用jQuery进行此操作
  • 所有的值都是数据库的动态字段

字段名
添加
编辑
删去
字段1
字段2

$(文档).ready(函数(){
$(“表tr:first input[type=checkbox]”)。单击(函数(){
var selector=“输入[type=checkbox]:[name=“+$(this).attr(“name”)+”];
$(选择器).attr(“选中”),$(此).attr(“选中”);
});
});
字段名
添加
编辑
删去
字段1
字段2

请为您的表提供一个id,如
id=“mytable”
并使用此代码

$("#mytable tr:first input[type=checkbox]").click(function() {
    var selector = $("#mytable td:first-child input[type=checkbox]")
    if (this.checked) {
        $(selector).attr("checked", "checked");
    }
    else {
        $(selector).removeAttr("checked");
    }
});

工作演示:

欢迎来到SO。请不要使用“紧急”和“全部”之类的词。你可能会因此得到反对票。你尝试过什么,什么不起作用?我们这里处理的是坏代码,不是请求。我试着检查它的所有工作情况。我不知道如何选择特定的行?每个人都想得到的是,@sathishkumar,我们不想为你做这项工作。如果你给我们展示你尝试过的东西,我们很乐意帮助你解决问题。在那之前,你没有给我们任何合作的机会。
  <script>
    $(document).ready(function () {
        $("table tr:first input[type=checkbox]").click(function () {
            var selector = "input[type=checkbox]:[name=" + $(this).attr("name") + "]";
            $(selector).attr("checked", $(this).attr("checked"));
        });
    });
</script>
 <table width="100%">
        <tr style="background: #999; color: #FFF;">
            <td>
                <input class="checkbox" type="checkbox" name="field_name" value="yes" id="Checkbox1" />
                <label for="field_name" class="checkboxlabel">
                    Field Name</label>
            </td>
            <td>
                <input class="checkbox" type="checkbox" name="Add" value="yes" id="Checkbox2" />
                <label for="default" class="checkboxlabel">
                    Add</label>
            </td>
            <td>
                <input class="checkbox" type="checkbox" name="Edit" value="yes" id="Checkbox3" />
                <label for="default" class="checkboxlabel">
                    Edit</label>
            </td>
            <td>
                <input class="checkbox" type="checkbox" name="delete" value="yes" id="Checkbox4" />
                <label for="default" class="checkboxlabel">
                    Delete</label>
            </td>
        </tr>
        <tr class="row1">
            <td>
                <input class="checkbox" type="checkbox" name="field_name" value="yes" id="field_1" />
                <label for="field_1" class="checkboxlabel">
                    Field 1</label>
            </td>
            <td align="center">
                <input class="checkbox" type="checkbox" name="Add" value="yes" id="Checkbox5" />
            </td>
            <td align="center">
                <input class="checkbox" type="checkbox" name="Edit" value="yes" id="Checkbox6" />
            </td>
            <td align="center">
                <input class="checkbox" type="checkbox" name="delete" value="yes" id="Checkbox7" />
            </td>
        </tr>
        <tr class="row2">
            <td>
                <input class="checkbox" type="checkbox" name="field_name" value="yes" id="field_1" />
                <label for="field_1" class="checkboxlabel">
                    Field 2</label>
            </td>
            <td align="center">
                <input class="checkbox" type="checkbox" name="Add" value="yes" id="Checkbox8" />
            </td>
            <td align="center">
                <input class="checkbox" type="checkbox" name="Edit" value="yes" id="Checkbox9" />
            </td>
            <td align="center">
                <input class="checkbox" type="checkbox" name="delete" value="yes" id="Checkbox10" />
            </td>
        </tr>
    </table>
$("#mytable tr:first input[type=checkbox]").click(function() {
    var selector = $("#mytable td:first-child input[type=checkbox]")
    if (this.checked) {
        $(selector).attr("checked", "checked");
    }
    else {
        $(selector).removeAttr("checked");
    }
});