Home  >  Article  >  Web Front-end  >  Javascript gets the number selected in CheckBoxList_javascript skills

Javascript gets the number selected in CheckBoxList_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:43:131181browse

jQuery's selectors are really powerful and flexible. JavaScript's original approach is also worth looking into.

Copy code The code is as follows:

<%@ Page Language="C#" AutoEventWireup= "true" CodeFile="CheckBoxList.aspx.cs" Inherits="CheckBoxList" %>








jQuery's selector is really powerful and flexible.

The original method of javascript is also worth studying.




1
2
< ;asp:ListItem>3










using System;
using System.Data;
using System .Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls ;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CheckBoxList : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnOk_Click(object sender, EventArgs e)
{
int totalNum = 0;//Total number
string list = "000"; //Selected value
for (int i = 0; i < this.chkBox.Items.Count; i )
{
if (chkBox.Items[i].Selected )
{
totalNum = 1;
list = "," chkBox.Items[i].Value;
}
}
Response.Write(totalNum.ToString() " |" list);
}
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn