报子页面获取checkboxlist的值为空!,请高手看看
这是子页面的代码如下:
function onOk() {
var chk = document.getElementById("<%=CheckBoxList1.ClientID %>");
var c = "";
window.returnValue = new Array;
for (var i = 0; i < chk.length; i++) {
if (chk.checked) {
c = chk[i].value;
}
break;
}
window.returnValue.chk = c;
window.close();
}
这是父页面的代码如下:
function showYeTai() {
var strurl = "YeTai.aspx";
var winstyle = 'dialogWidth=345px;dialogHeight=400px;status=no;scroll=no;help=no;resizable:no';
var yetai = window.showModalDialog(strurl, null, winstyle); if (yetai != null) {
document.getElementById("<%=txtYeTai.ClientID %>>").value=yetai.chk;
}
}
这是子页面的代码如下:
function onOk() {
var chk = document.getElementById("<%=CheckBoxList1.ClientID %>");
var c = "";
window.returnValue = new Array;
for (var i = 0; i < chk.length; i++) {
if (chk.checked) {
c = chk[i].value;
}
break;
}
window.returnValue.chk = c;
window.close();
}
这是父页面的代码如下:
function showYeTai() {
var strurl = "YeTai.aspx";
var winstyle = 'dialogWidth=345px;dialogHeight=400px;status=no;scroll=no;help=no;resizable:no';
var yetai = window.showModalDialog(strurl, null, winstyle); if (yetai != null) {
document.getElementById("<%=txtYeTai.ClientID %>>").value=yetai.chk;
}
}
if (chk.checked) {
c = chk[i].value;
}
break;
}
这里的chk.checked是不是应该是chk[i].checked呢,还有你的break,是不是应该放到if里面呢。2.document.getElementById("<%=txtYeTai.ClientID %>>").value=yetai.chk;这里两个>>会不会有问题呢?