gridview中的checkbox问题

zdl110110 2009-06-13 04:06:16
我的一个gridview控件每一列都是TemplateField,某一列TemplateField用的是checkboxlist.其他列用的是TextBox,除此之外,页面还用到了模板页,所以,生成的页面里边有下面的代码
<table id="ctl00_ContentPlaceHolder1_GridView1_ctl02_choicesCheckBox" border="0"> <tr><td><input id="ctl00_ContentPlaceHolder1_GridView1_ctl02_choicesCheckBox_0" type="checkbox" name="ctl00$ContentPlaceHolder1$GridView1$ctl02$choicesCheckBox$0" /><label for="ctl00_ContentPlaceHolder1_GridView1_ctl02_choicesCheckBox_0">取消</label></td><td><input id="ctl00_ContentPlaceHolder1_GridView1_ctl02_choicesCheckBox_1" type="checkbox" name="ctl00$ContentPlaceHolder1$GridView1$ctl02$choicesCheckBox$1" /><label for="ctl00_ContentPlaceHolder1_GridView1_ctl02_choicesCheckBox_1">减少</label></td>
</tr>
</table>
</td><td>
<span id="ctl00_ContentPlaceHolder1_GridView1_ctl02_IDLabel" style="display:inline-block;width:30px;position: relative">931149</span>
</td><td>
<input name="ctl00$ContentPlaceHolder1$GridView1$ctl02$S_TextBox" type="text" value="0" id="ctl00_ContentPlaceHolder1_GridView1_ctl02_S_TextBox" style="width:30px;position: relative" />
</td>
现在需要在客户端使用Javascript脚本实现全选功能,如何实现不通过getelementbyname 跟getelementbyid的方法来区分生成的所有html<input>标签。
...全文
34 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zdl110110 2009-06-15
  • 打赏
  • 举报
回复
虽然不是我想要的,还是给分了。
caiying2009 2009-06-13
  • 打赏
  • 举报
回复

<td>
<table id="ctl00_ContentPlaceHolder1_GridView1_ctl02_choicesCheckBox" border="0"> <tr>
<td>
<input id="ctl00_ContentPlaceHolder1_GridView1_ctl02_choicesCheckBox_0" type="checkbox" name="ctl00$ContentPlaceHolder1$GridView1$ctl02$choicesCheckBox$0" />
<label for="ctl00_ContentPlaceHolder1_GridView1_ctl02_choicesCheckBox_0">取消 </label> </td>
<td>
<input id="ctl00_ContentPlaceHolder1_GridView1_ctl02_choicesCheckBox_1" type="checkbox" name="ctl00$ContentPlaceHolder1$GridView1$ctl02$choicesCheckBox$1" />
<label for="ctl00_ContentPlaceHolder1_GridView1_ctl02_choicesCheckBox_1">减少 </label> </td>
</tr></table>

</td>
<td>
<span id="ctl00_ContentPlaceHolder1_GridView1_ctl02_IDLabel" style="display:inline-block;width:30px;position: relative">931149 </span></td>
<td>
<input name="ctl00$ContentPlaceHolder1$GridView1$ctl02$S_TextBox" type="text" value="0" id="ctl00_ContentPlaceHolder1_GridView1_ctl02_S_TextBox" style="width:30px;position: relative" /></td>

<p>
<p>
<a id="check_all" href="###" onclick="checkAll(this)"> 全选</a>

<script language="javascript">
<!--
function checkAll(_this){
var t=_this.name=="all_check"?0:1
var obj=document.getElementsByTagName("input")
for (var i=0;i<obj.length;i++){
if (obj[i].type=="checkbox")obj[i].checked=t
}
_this.name=_this.name=="all_check"?"all_no_check":"all_check"
_this.innerHTML=_this.name=="all_check"?"全不选":"全选"

}
//-->
</script>

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧