Ale
Numero di messaggi : 24 Età : 45 Data d'iscrizione : 23.02.09
| Titolo: Verifica selezione campi in lista checkbox Ven Mag 15, 2009 11:42 am | |
| pagina di esempio per verificare che almeno 1 campo della vostra lista checkbox sia stato selezionato: PAGINA A - Codice:
-
<html> <head> <script type="text/javascript">
function verifica() { flg = 0; for(i=1;i<=5;i++) { var v = 'chk'+i; if(document.forms[0][v].checked == true) { flg = 1; break; } else { flg = 0; } } if(flg == 0) { alert("Nessun campo selezionato"); return false; } else { return true; } }
</script> </head> <body bgcolor="pink"> ciao<br> sei nella pagina a <br><br> <form name="prova" method="get" action="b.html">
<input type="checkbox" name='chk1'/>a<br> <input type="checkbox" name='chk2'/>b<br> <input type="checkbox" name='chk3'/>c<br> <input type="checkbox" name='chk4'/>d<br> <input type="checkbox" name='chk5'/>e<br>
<br> <input type="submit" value="ok" onclick="return verifica()"> </form>
</body> </html> PAGINA B - Codice:
-
<html> <head> </head> <body bgcolor="green"> benvenuto<br> nella pagina b! </body> </html> | |
|