You can see the effect after selecting 3
]<script>
function disableCheckBox() {
var obj=document.getElementsByTagName("input")
for(var i=0;i<obj.length;i++)
{
if ( !obj[i].checked )
obj[i].disabled = true;
}
}
function ableCheckBox() {
var obj=document.getElementsByTagName("input")
for(var i=0;i<obj.length;i++)
obj[i].disabled = false;
}
function check()
{
var obj=document.getElementsByTagName("input")
var sun=0;
for(var i=0;i<obj.length;i++)
{
if(obj[i].type=="checkbox" &&
obj[i].checked)
sun++;
if( sun< 3 )
{
ableCheckBox();
//break;
}
else if(sun == 3 )
{
disableCheckBox();
event.srcElement.checked=true;
break;
}
else if(sun > 3 )
{
event.srcElement.checked=false;
break;
}
}
}
</script>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn