javascript 很简单的问题....在线等 哦 不能通过id="dlist1_ctl00_dlist2_ctl00_CheckBoxList1_0"和name="dlist1$ctl00$dlist2$ctl00$CheckBoxList1$0"来获取checkbox对象只能通过<span 来回去<span里面的checkbox对象 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 写个偷懒方法,哈注:span 后面必须是 checkbox,否则就要修改js了。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title> new document </title> <meta name="generator" content="editplus" /> <meta name="author" content="Gao YiXiang" /> <meta name="email" content="[email protected]" /> <meta name="keywords" content="javascript dhtml dom" /> <meta name="description" content="I love web development." /></head><body> <table> <tr> <td> <span name="GET_ALL_ACCOUNTS_AGAIN" ckid="CheckBoxList1_"> <input id="dlist1_ctl00_dlist2_ctl00_CheckBoxList1_0" type="checkbox" name="dlist1$ctl00$dlist2$ctl00$CheckBoxList1$0" /> <label for="dlist1_ctl00_dlist2_ctl00_CheckBoxList1_0"> 重新统计会员积分 </label> </span> </td> <td> </tr> </table> <script type="text/javascript"> <!--var spans = document.getElementsByTagName("span");for (var i=0; i<spans.length; i++){ spans[i].firstChild.checked = true;} //--> </script></body></html> <html><head><title> new document </title><script language="javascript">function Sel(){var obj=document.getElementsByTagName('input');for(var i=0;i<obj.length;i++){if(obj[i].type="checkbox"){obj[i].checked=true;}}}</script></head><body><span><input type="checkbox" name="table_name"> <input type="checkbox" name="table_name"> <input type="checkbox" name="table_name"> <input type="checkbox" name="table_name"> <INPUT TYPE="button" name="bt1" id="bt1" value=" selectAll " onclick="Sel()"></span></body></html> <script language="javascript" type="text/javascript" charset="utf-8">var checkboxs = document.getElementByTagName("input");for (var i=0;i<checkboxs.lenght;i++){ if (checkboxs[i].type.toLowerCase() == "checkbox") {checkboxs[i].checked = true;}} </script> 因为一部分input的信息一定要写在SPAN里面,所以只能通过SPAN获取 改一版,L@_@K<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title> new document </title> <meta name="generator" content="editplus" /> <meta name="author" content="Gao YiXiang" /> <meta name="email" content="[email protected]" /> <meta name="keywords" content="javascript dhtml dom" /> <meta name="description" content="I love web development." /> <style type="text/css">span{ border: 1px solid red;} </style></head><body> <input id="c1" type="checkbox" name="" /> <label for="c1"> 非 span 滴 重新统计会员积分 </label> <table> <tr> <td> <span name="GET_ALL_ACCOUNTS_AGAIN" ckid="CheckBoxList1_"> <input id="dlist1_ctl00_dlist2_ctl00_CheckBoxList1_0" type="checkbox" name="dlist1$ctl00$dlist2$ctl00$CheckBoxList1$0" /> <label for="dlist1_ctl00_dlist2_ctl00_CheckBoxList1_0"> 重新统计会员积分 </label> </span> </td> <td> </tr> <tr> <td> <span name="GET_ALL_ACCOUNTS_AGAIN" ckid="CheckBoxList1_"> 没有 checkbox 重新统计会员积分 </span> </td> <td> </tr> <tr> <td> <span name="GET_ALL_ACCOUNTS_AGAIN" ckid="CheckBoxList1_"> <input id="dlist1_ctl00_dlist2_ctl00_CheckBoxList1_1" type="checkbox" name="dlist1$ctl00$dlist2$ctl00$CheckBoxList1$1" /> <label for="dlist1_ctl00_dlist2_ctl00_CheckBoxList1_1"> 有 checkbox 重新统计会员积分 </label> </span> </td> <td> </tr> </table> <input id="c2" type="checkbox" name="" /> <label for="c2"> 非 span 滴 重新统计会员积分 </label> <script type="text/javascript"> <!--var spans = document.getElementsByTagName("span");var inputs, aInput;for (var i=0; i<spans.length; i++){ inputs = spans[i].getElementsByTagName("input"); for (var j=0; j<inputs.length; j++) { aInput = inputs[j]; if (aInput.type.toLowerCase() == "checkbox") { aInput.checked = true; } }} //--> </script></body></html> 如何做一个界面,让背后变灰,按界面后的关闭键才恢复正常。 为啥会有javascript这脚本诞生——困 js的function函数里面的失去焦点事件如何写? AJAX小聊天室火狐不兼容 有没有办法让text控件的最后两个位置无效,留下位置实现有点类似下拉框右边的按钮 江湖救急:请问javascript中能否实现以下操作数据库的功能? 请问下如何在弹出的框架中获取前面页面传递的值 急急!求教如何固定工具栏的代码 帮帮忙,怎么把光标定位在字母ab之间? javascript有没有goto语句? 如何添加鼠标右键菜单 请教一个小问题,高手帮忙看下!~谢谢了!!!!!!!!!!!!!!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="[email protected]" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
</head>
<body>
<table>
<tr>
<td> <span name="GET_ALL_ACCOUNTS_AGAIN" ckid="CheckBoxList1_"> <input id="dlist1_ctl00_dlist2_ctl00_CheckBoxList1_0" type="checkbox" name="dlist1$ctl00$dlist2$ctl00$CheckBoxList1$0" /> <label for="dlist1_ctl00_dlist2_ctl00_CheckBoxList1_0"> 重新统计会员积分 </label> </span> </td> <td>
</tr>
</table>
<script type="text/javascript">
<!--
var spans = document.getElementsByTagName("span");
for (var i=0; i<spans.length; i++)
{
spans[i].firstChild.checked = true;
}
//-->
</script>
</body>
</html>
<html>
<head>
<title> new document </title>
<script language="javascript">
function Sel(){
var obj=document.getElementsByTagName('input');
for(var i=0;i<obj.length;i++){
if(obj[i].type="checkbox"){
obj[i].checked=true;
}
}
}
</script>
</head>
<body>
<span>
<input type="checkbox" name="table_name">
<input type="checkbox" name="table_name">
<input type="checkbox" name="table_name">
<input type="checkbox" name="table_name">
<INPUT TYPE="button" name="bt1" id="bt1" value=" selectAll " onclick="Sel()">
</span>
</body>
</html>
var checkboxs = document.getElementByTagName("input");
for (var i=0;i<checkboxs.lenght;i++)
{
if (checkboxs[i].type.toLowerCase() == "checkbox") {checkboxs[i].checked = true;}
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="[email protected]" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
<style type="text/css">
span
{
border: 1px solid red;
}
</style>
</head>
<body>
<input id="c1" type="checkbox" name="" /> <label for="c1"> 非 span 滴 重新统计会员积分 </label>
<table>
<tr>
<td> <span name="GET_ALL_ACCOUNTS_AGAIN" ckid="CheckBoxList1_"> <input id="dlist1_ctl00_dlist2_ctl00_CheckBoxList1_0" type="checkbox" name="dlist1$ctl00$dlist2$ctl00$CheckBoxList1$0" /> <label for="dlist1_ctl00_dlist2_ctl00_CheckBoxList1_0"> 重新统计会员积分 </label> </span> </td> <td>
</tr>
<tr>
<td> <span name="GET_ALL_ACCOUNTS_AGAIN" ckid="CheckBoxList1_"> 没有 checkbox 重新统计会员积分 </span> </td> <td>
</tr>
<tr>
<td> <span name="GET_ALL_ACCOUNTS_AGAIN" ckid="CheckBoxList1_"> <input id="dlist1_ctl00_dlist2_ctl00_CheckBoxList1_1" type="checkbox" name="dlist1$ctl00$dlist2$ctl00$CheckBoxList1$1" /> <label for="dlist1_ctl00_dlist2_ctl00_CheckBoxList1_1"> 有 checkbox 重新统计会员积分 </label> </span> </td> <td>
</tr>
</table>
<input id="c2" type="checkbox" name="" /> <label for="c2"> 非 span 滴 重新统计会员积分 </label>
<script type="text/javascript">
<!--
var spans = document.getElementsByTagName("span");var inputs, aInput;for (var i=0; i<spans.length; i++)
{
inputs = spans[i].getElementsByTagName("input"); for (var j=0; j<inputs.length; j++)
{
aInput = inputs[j]; if (aInput.type.toLowerCase() == "checkbox")
{
aInput.checked = true;
}
}
}
//-->
</script>
</body>
</html>