<script language="JavaScript">
<!--
function cek(){
	counter=0;
	for(i=1;i<10;i++){
	//	i=1;
		if(document.getElementById('a'+i).checked==true){
			//alert('aaddd');
			counter++;
		}
	}
	
	if(counter==2){
		//alert('adadeh');
		for(i=1;i<=10;i++){
			if(document.getElementById('a'+i).checked==true){
				continue;
			}else{
				document.getElementById('a'+i).disabled=true;
			}
			
		}
	}/*
	}else{
		for(i=1;i<=9;i++){
			document.getElementById('a'+i).disabled=false;
		}
	}*/
}


//-->
</script>
<pre>
<form NAME="formnya" action="script1.html" method="post">
1.<input type="checkbox" id="a1" name="pilihan[]" value="satu" onclick="cek()">satu
2.<input type="checkbox" id="a2" name="pilihan[]" value="dua" onclick="cek()">dua
3.<input type="checkbox" id="a3" name="pilihan[]" value="tiga" onclick="cek()">tiga
4.<input type="checkbox" id="a4" name="pilihan[]" value="empat" onclick="NgebatesinCheck()">empat
5.<input type="checkbox" id="a5" name="pilihan[]" value="lima" onclick="NgebatesinCheck()">lima
6.<input type="checkbox" id="a6" name="pilihan[]" value="enam" onclick="NgebatesinCheck()">enam
7.<input type="checkbox" id="a7" name="pilihan[]" value="tujuh" onclick="NgebatesinCheck()">tujuh
8.<input type="checkbox" id="a8" name="pilihan[]" value="delapan" onclick="NgebatesinCheck()">delapan
9.<input type="checkbox" id="a9" name="pilihan[]" value="sembilan" onclick="NgebatesinCheck()">sembilan
10.<input type="checkbox" id="10" name="pilihan[]" value="sepuluh" onclick="NgebatesinCheck()">sepuluh
<input type="submit" name="btkirim" value="KIRIM" disabled>
</form>

this is script for allow user choose max 2 choice and disable others checkbox, my problem is if we check 2 checkbox is working but if we un check one of the checkbox which had checked the other checkbox is enable again..

This article has been dead for over six months. Start a new discussion instead.