js 取得CheckBoxList的选中项的值

本文介绍了一个使用JavaScript实现的父页面与子页面之间的数据传递示例。通过使用showModalDialog展示子页面,并通过CheckBoxList选择数据后返回给父页面的TextBox控件。
父页面:(TextBox1用来接收子页面(user_code.aspx)传回来的值)
<script language="javascript" type="text/javascript">
function show_win()
{    
    
var var_win = 0;
    showModalDialog('user_code.aspx',[window,document.getElementById(
"TextBox1").id],'status:Modeless;edge:raised;unadorned:no;scroll=no;resizable:yes;center:yes;help:no;dialogwidth:520px;dialogheight:420px');
    
}

</script>
子页面(user_code.aspx):
 <script language="javascript" type="text/javascript">
    
function selected_info(str)
    
{
       
          
var CheckBoxList=document.all.CheckBoxList1;             
          
var textbox=document.all.hid_user_code;   
          textbox.value
="";   
          
var objCheckBox ;
          
for(i=0;i<CheckBoxList.rows.length;i++)   
          
{   
                objCheckBox   
=   document.getElementById("CheckBoxList1_"   +   i); 
                
                
if(objCheckBox.checked == true)
                
{
                    textbox.value 
+= CheckBoxList.rows[i].cells[0].childNodes(1).innerText + ",";   
                }

          }
   
          
           
          window.dialogArguments[
0].document.getElementById(window.dialogArguments[1]).value = textbox.value;
          window.close();
    }


    
</script>


<form>
 
<div>
        
&nbsp;
<table style="width: 403px; height: 282px">
            
<tr>
                
<td style="width: 100px">
                     
<asp:Label ID="Label1" runat="server" Text="用户编号:" Width="72px"></asp:Label>
                
</td>
            
</tr>
            
<tr>
                
<td style="width: 100px">
                    
<asp:CheckBoxList ID="CheckBoxList1" runat="server" >  </asp:CheckBoxList>
                
</td>
            
</tr>
        
</table>
        
<hr />
        
<asp:Button ID="btn_confirm" runat="server" Text="确定"  />
       
</div>
       
<input id="hid_user_code" runat="server" type="text" />
    
</form>

转载于:https://www.cnblogs.com/simhare/archive/2007/10/16/926160.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值