日期:2014-05-17 浏览次数:20578 次
.. ... CheckBox ckb = null; for (int i = 0; i < dt.Rows.Count; i++) { //注意不是HTML的checkbox ckb = new CheckBox(); ckb.ID = string.Format("chk{0}", i.ToString()); ckb.Text = string.Format(dt.Rows[i][2].ToString(), i);//JS要获取它的值 ckb.CheckedChanged += new EventHandler(ckb_CheckedChanged); //ckb.Location = new Point(0, i * 20); ckb.Checked = false; Page.Form.Controls.Add(ckb); } //js代码如下 function aa() { var objs = document.getElementsByTagName("input"); //拼凑的字符串 var str = ''; //遍历 for (var i = 0; i < objs.length; i++) {//遍历所有的,被选中的复选框 if (objs[i].type.toLowerCase() == "checkbox" && objs[i].checked) //连接客串 //str = str + objs[i].nextSibling.nodeValue + ',';//这样取到的是null str = str + objs[i].value + ',';//这样取到的是on } window.returnValue = str; window.close(); }
function aa() { var objs = document.getElementsByTagName("input"); //拼凑的字符串 var str = ''; //遍历 for (var i = 0; i < objs.length; i++) {//遍历所有的,被选中的复选框 if (objs[i].type.toLowerCase() == "checkbox" && objs[i].checked) //连接客串 var label = document.getElementById(objs[i].id).nextSibling; str = str + label.innerHTML + ','; } window.returnValue = str; window.close(); }