【问题标题】:Read values from multiple radioButtonLists in a Grid从 Grid 中的多个 radioButtonLists 中读取值
【发布时间】:2015-11-13 19:14:30
【问题描述】:

我正在创建一个出勤页面,其中学生显示在网格中,并且必须使用单选按钮将每个学生标记为出席、缺席或休假。

考勤页面截图:

我只能使用 jQuery 选择第一个学生的状态,而不能选择其他学生的状态。

这是我的代码:

<script type="text/javascript">
    $(function() {
        $('[id*=btnsave]').on('click', function() {
            var val = "";
            val = $('[id*=RBL1]').find('input:checked').val();
            if (val != "" && val != undefined) {
                alert("The value of the selected item is : " + val)
            }
            else {
                alert("No item in the RadioButton List Selected !!");
            }
        });
    });
</script>

如何使用类似循环的方式选择其他学生的状态?

【问题讨论】:

    标签: jquery .net radiobuttonlist


    【解决方案1】:

    是的,您应该在单选按钮列表中添加一个类并对其进行迭代,它应该是这样的:

      $('.rbl').each(function() {
            var checked = $(this).find('input:radio:checked');
            if (checked.length == 0) {
                alert("No item in the RadioButton List Selected !!");
            }
            else{
                ......`enter code here`
            }
    
      });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-07
      • 1970-01-01
      • 1970-01-01
      • 2020-04-02
      • 2012-11-06
      • 2015-07-16
      • 2011-12-23
      • 2016-03-25
      相关资源
      最近更新 更多