单选框的选择问题 都是a组的,又是单选框,如何实现全选?? 如果改组名,那还不如用checkbox. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <br><input type=checkbox name="a">a <input type=checkbox name="b">b<br><input type=checkbox name="a">a <input type=checkbox name="b">b<br><input type=checkbox name="a">a <input type=checkbox name="b">b<br><input type=checkbox name="a">a <input type=checkbox name="b">b<br><input type=checkbox name="a">a <input type=checkbox name="b">b<br><input type=checkbox name="a">a <input type=checkbox name="b">b<br>全选A<input type=checkbox onclick="selectAllCheckboxes('a',this.checked);"><br>全选B<input type=checkbox onclick="selectAllCheckboxes('b',this.checked);"><script>/*** This function is to change all checkboxes to checked or unchecked.* JK 2003-12-08*/function selectAllCheckboxes(nameOfCheckBox,trueOrFalse){ if(trueOrFalse==null) trueOrFalse=true; var theCheckboxInputs=document.getElementsByName(nameOfCheckBox); for (var i=0;i<theCheckboxInputs.length;i++) theCheckboxInputs[i].checked=trueOrFalse;}</script> function selecta(){ var objs = document.getElementsByName('a'); var i=0; for(i = 0 ; i < objs.length ; i ++) { if(objs[i].checked ==true) { objs[i].checked =false; } else { objs[i].checked =true; } }}function selectb(){ var objs = document.getElementsByName('b'); var i=0; for(i = 0 ; i < objs.length ; i ++) { if(objs[i].checked ==true) { objs[i].checked =false; } else { objs[i].checked =true; } }} <br><input type=radio name="a1">a <input type=radio name="a1">b<br><input type=radio name="a2">a <input type=radio name="a2">b<br><input type=radio name="a3">a <input type=radio name="a3">b<br><input type=radio name="a4">a <input type=radio name="a4">b<br><input type=radio name="a5">a <input type=radio name="a5">b<br><input type=radio name="a6">a <input type=radio name="a6">b<br>全选A<input type=radio name=JK onclick="selectAll(0)"><br>全选B<input type=radio name=JK onclick="selectAll(1)"><script>function selectAll(redioIndex){for(var i=1;i<7;i++) document.all("a"+i)[redioIndex].checked=true;}</script> radio 用来使用户来单选一个选项的checkbox 使用来给用户进行多选的!楼主何必非要绕弯路呢! 帮忙看一下一段js代码 讨论变量初始赋值的好处 onclick="return on()";当on()返回flase,回怎样?那返回为true,又会怎么样? 求助一个比较难的jquery效果 怎么才能让用js脚本写的漂浮广告不被Flash遮住? table 获取单元格的对应列数 zip.js 读取压缩文件存入沙盒崩溃的问题 已知程序文件的完整路径,怎么用 javascript打开它呢?拜托了………… 请教如何得到html页中帧页面的大小 【问题】if用一个按钮来交替调用两个css文件无效 请问怎么样得到多行文本框中光标的位置/选择的文本? 那里有试题??
<br><input type=checkbox name="a">a <input type=checkbox name="b">b
<br><input type=checkbox name="a">a <input type=checkbox name="b">b
<br><input type=checkbox name="a">a <input type=checkbox name="b">b
<br><input type=checkbox name="a">a <input type=checkbox name="b">b
<br><input type=checkbox name="a">a <input type=checkbox name="b">b
<br><input type=checkbox name="a">a <input type=checkbox name="b">b
<br>全选A<input type=checkbox onclick="selectAllCheckboxes('a',this.checked);">
<br>全选B<input type=checkbox onclick="selectAllCheckboxes('b',this.checked);"><script>
/**
* This function is to change all checkboxes to checked or unchecked.
* JK 2003-12-08
*/
function selectAllCheckboxes(nameOfCheckBox,trueOrFalse)
{
if(trueOrFalse==null) trueOrFalse=true;
var theCheckboxInputs=document.getElementsByName(nameOfCheckBox);
for (var i=0;i<theCheckboxInputs.length;i++)
theCheckboxInputs[i].checked=trueOrFalse;
}
</script>
{
var objs = document.getElementsByName('a');
var i=0;
for(i = 0 ; i < objs.length ; i ++)
{
if(objs[i].checked ==true)
{
objs[i].checked =false;
}
else
{
objs[i].checked =true;
}
}
}function selectb()
{
var objs = document.getElementsByName('b');
var i=0;
for(i = 0 ; i < objs.length ; i ++)
{
if(objs[i].checked ==true)
{
objs[i].checked =false;
}
else
{
objs[i].checked =true;
}
}
}
<br><input type=radio name="a2">a <input type=radio name="a2">b
<br><input type=radio name="a3">a <input type=radio name="a3">b
<br><input type=radio name="a4">a <input type=radio name="a4">b
<br><input type=radio name="a5">a <input type=radio name="a5">b
<br><input type=radio name="a6">a <input type=radio name="a6">b
<br>全选A<input type=radio name=JK onclick="selectAll(0)">
<br>全选B<input type=radio name=JK onclick="selectAll(1)"><script>function selectAll(redioIndex)
{
for(var i=1;i<7;i++)
document.all("a"+i)[redioIndex].checked=true;
}
</script>