JavaScript - CHECKBOX (AYUDA!!!)

 
Vista:

CHECKBOX (AYUDA!!!)

Publicado por Jesus Miguel (9 intervenciones) el 27/09/2001 14:07:03
Mi problema es el siguiente, tengo un conjunto de checkbox entonces quiero que de ese conjunto de checkbox solo me puedan elegir tres y que no me puedan elegir un cuarto, tambien controlar si cambian de Checkbox.

Gracias Anticipadamente.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:CHECKBOX (AYUDA!!!)

Publicado por victor (54 intervenciones) el 27/09/2001 20:42:08
<html>
<head>
<title>Suerte</title>
<script language="JavaScript">
<!--
function limite(n, t)
{
c = 0;
for (x=0;x<t.chb.length;x++)
if (t.chb[x].checked)
c++
if (c > 3 && n.checked)
n.checked = false;
}
-->
</script>
</head>
<body>
<form name="hola" action="" onSubmit="return false">
<input type="checkbox" name="chb" value="1" onClick="limite(this, this.form)">1<br>
<input type="checkbox" name="chb" value="2" onClick="limite(this, this.form)">2<br>
<input type="checkbox" name="chb" value="3" onClick="limite(this, this.form)">3<br>
<input type="checkbox" name="chb" value="4" onClick="limite(this, this.form)">4<br>
<input type="checkbox" name="chb" value="5" onClick="limite(this, this.form)">5<br>
<input type="checkbox" name="chb" value="6" onClick="limite(this, this.form)">6<br>
</form>
</body>
</html>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar