日期:2014-05-16  浏览次数:20325 次

琢磨半天没有结果,召唤CheckBoxList大师进
语言C#,页面放2个服务器端控件 <asp:CheckBoxList> 和 <asp:DropDownList> ,在.cs文件中绑定CheckBoxList的数据

希望实现的效果是,不刷新页面,点击CheckBox时把选中的值添加到DropDownList中

根据jianye112的提示,已经实现了功能,但是我却怎么也取不到CheckBoxList的Text,一开始用getElementById,取到的只是“on”,后来又想根据getElementsByTagName( "input ")得到checked的index,但是返回的值是undefind,后来又想通过CheckBoxList生成的 <table> ,用DOM模型来取,依然找不到,晕啊,到底该怎么取呢?

===================CheckBoxList生成的客户端代码===============

<table   id= "cblTeamPerson "   cellspacing= "20 "   border= "0 ">
<tr>
<td> <input   id= "cblTeamPerson_0 "   type= "checkbox "   name= "cblTeamPerson$0 "   /> <label   for= "cblTeamPerson_0 "> ter </label> </td> <td> <input   id= "cblTeamPerson_1 "   type= "checkbox "   name= "cblTeamPerson$1 "   /> <label   for= "cblTeamPerson_1 "> 5ye </label> </td> <td> <input   id= "cblTeamPerson_2 "   type= "checkbox "   name= "cblTeamPerson$2 "   /> <label   for= "cblTeamPerson_2 "> 第三个 </label> </td> <td> <input   id= "cblTeamPerson_3 "   type= "checkbox "   name= "cblTeamPerson$3 "   /> <label   for= "cblTeamPerson_3 "> ryu </label> </td> <td> <input   id= "cblTeamPerson_4 "   type= "checkbox "   name= "cblTeamPerson$4 "   /> <label   for= "cblTeamPerson_4 "> 第二个 </label> </td>
</tr> <tr>
<td> <input   id= "cblTeamPerson_5 "   type= "checkbox "   name= "cblTeamPerson$5 "   /> <label   for= "cblTeamPerson_5 "> -1 </label> </td> <td> <input   id= "cblTeamPerson_6 "   type= "checkbox "   name= "cblTeamPerson$6 "   /> <label   for= "cblTeamPerson_6 "> 第五个 </label> </td> <td> <input   id= "cblTeamPerson_7 "   type= "checkbox "   name= "cblTeamPerson$7 "   /> <label   for= "cblTeamPerson_7 "> 第四个 </label> </td> <td> <input   id= "cblTeamPerson_8 "   type= "checkbox "   name= "cblTeamPerson$8 "   /> <label   for= "cblTeamPerson_8 "> 5555 </label> </td> <td> </td>
</tr>
</table>


==================JavaScript代码============================


//   Get   the   event.onclick   Text
                function   getText(checkBoxID)
                {
                        //   找到checkboxlist
                        var   checkBoxList   =   document.getElementById( "cblTeamPerson ");
                        //   获取里面的选项
                        var   checkbox   =   checkBoxList.getElementsByTagName( "input ");