我的一个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>标签。
<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>标签。
解决方案 »
- Node.js的问题 高手给看下
- select列表框中的选项顺序能不能调整
- <select name="Household" id="Household">取得Select的显示文字,不是value因为值是数字,需要得到显示的汉字
- 能帮我把懲标做成旋转或者其他样式吗
- 请问window.isBusy是什么意思?它有什么作用?
- JS脚本如何将文本替换回车?
- javascript检查表格是否输入正确,谢谢!!
- 菜鸟问题:多维数组的定义、使用?
- 一个表格问题!!!!!!!
- jquery.fileupload 插件, 成功回调函数不执行
- 大家帮忙看下Extjs的问题
- document.body.scrollTop,这个属性应该到文档的哪里去查?
<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>