function test( theCheckObj )
{
var the = document.getElementByName( theCheckObj.name )
//checkBoxName 是你那三个名字相同的checkbox的名字
for( var i = 0 ; i < the.length ; i++ )
{
if( the[ i ].value == theCheckObj.value )
{
the[ i ].checked = theCheckObj.checked
}
}
}
------------
<input name=aa type=checkbox value="..." onclick="test( this )" />
<input name=aa type=checkbox value="..." onclick="test( this )" />
<input name=aa type=checkbox value="..." onclick="test( this )" />
<input name=aa type=checkbox value="..." onclick="test( this )" />
<input name=aa type=checkbox value="..." onclick="test( this )" />
{
var the = document.getElementByName( theCheckObj.name )
//checkBoxName 是你那三个名字相同的checkbox的名字
for( var i = 0 ; i < the.length ; i++ )
{
if( the[ i ].value == theCheckObj.value )
{
the[ i ].checked = theCheckObj.checked
}
}
}
------------
<input name=aa type=checkbox value="..." onclick="test( this )" />
<input name=aa type=checkbox value="..." onclick="test( this )" />
<input name=aa type=checkbox value="..." onclick="test( this )" />
<input name=aa type=checkbox value="..." onclick="test( this )" />
<input name=aa type=checkbox value="..." onclick="test( this )" />
<body>
<script>
function test( theCheckObj )
{
var the = document.getElementsByName( theCheckObj.name )
//checkBoxName 是你那三个名字相同的checkbox的名字
for( var i = 0 ; i < the.length ; i++ )
{
if( the[ i ].value == theCheckObj.value )
{
the[ i ].checked = theCheckObj.checked
}
}
}</script>
------------
<input name=aa type=checkbox value="..." onclick="test( this )" />
<input name=aa type=checkbox value="..." onclick="test( this )" />
<input name=aa type=checkbox value="..." onclick="test( this )" />
<input name=aa type=checkbox value="..." onclick="test( this )" />
<input name=aa type=checkbox value="..." onclick="test( this )" />
</body>
</html>
getElementsByName 写成了 getElementByName