首页 > 其他 > 详细

获取CheckBox的值

时间:2017-04-27 15:21:51      阅读:216      评论:0      收藏:0      [点我收藏+]

前台获取

   function chkCheckBox() {
            var code_arr = new Array(); //定义一数组
            $(.C_B).each(function () {
                if ($(this).prop("checked")) {
                    if ($(this).val() != "")
                    code_arr.push($(this).val());
                }
            });
            if (code_arr.length == "") {
                alert("请先选择之后再点击下一步!");
                return false;
            }
            return true;
        }

后台获取 asp.net webform情况下的

<td>
      <input type="checkbox" value=<%# Eval("ID") %> id="Check_Box" class="C_B" runat="server" /> 
 </td>
        /// <summary>
        /// 下一步按钮
        /// </summary>
        protected void btnnext_Click(object sender, EventArgs e)
        {
            List<string> IdArr = new List<string>();
          
            //遍历repeater控件的itemtemplate模版  
            foreach (RepeaterItem item in rptData.Items)
            {
                HtmlInputCheckBox cb = (HtmlInputCheckBox)item.FindControl("Check_Box"); //根据控件id获得控件对象,cdDelete是checkBox控件的id  
                if (cb.Checked == true)
                {
                    IdArr.Add(cb.Value);
                }
            } 
        }

 

获取CheckBox的值

原文:http://www.cnblogs.com/youmingkuang/p/6774274.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!