Sto facendo delle prove per eserctarmi in javascript man mano che vado a vanti nello studio..
Voglio che se non sono checckate solo ed esclusivamente 2 checkbox si vede un messaggio di errore sotto..
codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
<script type="text/javascript">
function controlla(id){
var contacheck = 0
for(i=0;i<11;i++){
if(document.esempio.i.checked){
contachek++
}
}
if(contacheck =! 2){
alert("SBAGLIATO")
view('secondo')
view('nasc')
hidden('primo')
}else{
alert("GIUSTO")
}
}
function view(id) {
document.getElementById(id).style.display='block';
}
function hidden(id) {
document.getElementById(id).style.display='none';
}
</script>
</head>
<body>
<form name="esempio">
<input id="giocata" name="0" type="checkbox" value="" />
<input id="giocata" name="1" type="checkbox" value="" />
<input id="giocata" name="2" type="checkbox" value="" />
<input id="giocata" name="3" type="checkbox" value="" />
<input id="giocata" name="4" type="checkbox" value="" />
<input id="giocata" name="5" type="checkbox" value="" />
<input id="giocata" name="6" type="checkbox" value="" />
<input id="giocata" name="7" type="checkbox" value="" />
<input id="giocata" name="8" type="checkbox" value="" />
<input id="giocata" name="8" type="checkbox" value="" />
<input id="giocata" name="10" type="checkbox" value="" />
<input type="button" value="Gioca" id="primo" onclick="controlla(id);">
<input style="display: none" type="button" value="Gioca" id="secondo" onclick="view('primo');hidden('nasc');hidden('secondo')">
<span id="nasc" style="display: none">Massimo due giocate!</span>
</form>
</body>
</html>
L'errore esce su document.esempio.i.checked, non so come fare altrimenti, mi potee suggerire?