1.偷懒的方法:)
<table id="_ctl2_cblAction" border="0" style="width:277px;">
<tr>
<td><input id="_ctl2_cblAction_0" type="checkbox" name="_ctl2:cblAction:0" /><label for="_ctl2_cblAction_0">北京</label></td>
</tr>
<tr>
<td><input id="_ctl2_cblAction_1" type="checkbox" name="_ctl2:cblAction:1" /><label for="_ctl2_cblAction_1">天津</label></td>
</tr><tr>
<td><input id="_ctl2_cblAction_2" type="checkbox" name="_ctl2:cblAction:2" /><label for="_ctl2_cblAction_2">山西</label></td>
</tr>
</table>
<button onclick="getValue()">goooo</button>
<script language="JavaScript">
<!--
function getValue()
{
var obj = document.getElementsByTagName("input");
var str = "";
for(var i=0;i<obj.length;i++)
{
if(obj[i].type == "checkbox" && obj[i].checked == true)
str += obj[i].parentElement.innerText+",";
}
alert(str);
}
//-->
</script>
<table id="_ctl2_cblAction" border="0" style="width:277px;">
<tr>
<td><input id="_ctl2_cblAction_0" type="checkbox" name="_ctl2:cblAction:0" /><label for="_ctl2_cblAction_0">北京</label></td>
</tr>
<tr>
<td><input id="_ctl2_cblAction_1" type="checkbox" name="_ctl2:cblAction:1" /><label for="_ctl2_cblAction_1">天津</label></td>
</tr><tr>
<td><input id="_ctl2_cblAction_2" type="checkbox" name="_ctl2:cblAction:2" /><label for="_ctl2_cblAction_2">山西</label></td>
</tr>
</table>
<button onclick="getValue()">goooo</button>
<script language="JavaScript">
<!--
function getValue()
{
var obj = document.getElementsByTagName("input");
var str = "";
for(var i=0;i<obj.length;i++)
{
if(obj[i].type == "checkbox" && obj[i].checked == true)
str += obj[i].parentElement.innerText+",";
}
alert(str);
}
//-->
</script>
解决方案 »
- js如何写单击button按钮后datalist里的label的visible属性变为true
- class="disabled" 功能实现
- js怎么判断世界末日“2012-12-23”字符串对应的时间比今天大?
- EXTjs的ComboBox问题
- 如何用javascript实现逆环视?????(只支持正向环视....)
- javascript document.referrer属性试验
- 求段JS代码(要求能在IE6.0SP1下通过)
- 怎样使一个文本框不可修改,但post时仍然起效(照样能够post数据)
- 怎样把65转换成字母A?有什么函数?
- 怎么样能够得到另一个window中的网页的链接?
- 如何使注册页面不留痕迹?
- this is a test
str += obj[i].innerText+",";