选择指定的的checkbox
<!--实现功能,点击选定按钮后,ID为W1,W4,W7的复选框选上-->
function webchose(webstr)
{
函数
}
<form name=webform action= " " method=post>
<table border= "0 " width= "100% " id= "table2 ">
<tr>
<td> <input type=checkbox name= "WebId " id= "W1 " value= "1 "> dataa </td>
<td> <input type=checkbox name= "WebId " id= "W21 " value= "21 "> datab </td>
<td> <input type=checkbox name= "WebId " id= "W3 " value= "3 "> datac </td>
<td> <input type=checkbox name= "WebId " id= "W4 " value= "4 "> datad </td>
<td> <input type=checkbox name= "WebId " id= "W25 " value= "25 "> datae </td>
<td> <input type=checkbox name= "WebId " id= "W6 " value= "6 "> dataf </td>
<td> <input type=checkbox name= "WebId " id= "W7 " value= "7 "> datag </td>
<td> <input type=checkbox name= "WebId " id= "W8 " value= "8 "> datah </td>
</tr>
</table>
<input type=button value= "选定 " onclick= "webchose( 'W1,W4,W7 '); ">
</form>
------解决方案-------------------- <script type= "text/javascript ">
// <![CDATA[
function webchose(webstr)
{
var a=webstr.split(/\s*,\s*/);
for(var i=0, j=a.length; i <j; i++)
{
document.getElementById(a[i]).checked=true;
}
} // shawl.qiu script
//]]>
</script>
<form name=webform action= " " method=post>
<table border= "0 " width= "100% " id= "table2 ">
<tr>
<td> <input type=checkbox name= "WebId " id= "W1 " value= "1 "> dataa </td>
<td> <input type=checkbox name= "WebId " id= "W21 " value= "21 "> datab </td>
<td> <input type=checkbox name= "WebId " id= "W3 " value= "3 "> datac </td>
<td> <input type=checkbox name= "WebId " id= "W4 " value= "4 "> datad </td>
<td> <input type=checkbox name= "WebId " id= "W25 " value= "25 "> datae </td>
<td> <input type=checkbox name= "WebId " id= "W6 " value= "6 "> dataf </td>
<td> <input type=checkbox name= "WebId " id= "W7 " value= "7 "> datag </td>
<td> <input type=checkbox name= "WebId " id= "W8 " value= "8 "> datah </td>
</tr>
</table>
<input type=button value= "选定 " onclick= "webchose( 'W1,W4,W7 '); ">
</form>