Tengo un grupo de checkbox, solo tengo que seleccionar 3, pero en la base de datos me aparece on, en todos adjunto el código.

<div id="tapa"></div>
<label for="causas" class="">Selecciona sólo 3 opciones:</label><br>
<div class="col-sm-10" align="left">
<h5>¿Qué prodceso fallo?</h5>
<script>
function countChoices(obj) {
max = 3; // max. Number allowed at a time

a = obj.form.opcion[0].checked; // your checkboxes here
b = obj.form.opcion[1].checked;
c = obj.form.opcion[2].checked;
d = obj.form.opcion[3].checked;
e = obj.form.opcion[4].checked;
f = obj.form.opcion[5].checked;
g = obj.form.opcion[6].checked;
// add more if necessary

count = (a ? 1 : 0) + (b ? 1 : 0) + (c ? 1 : 0) + (d ? 1 : 0) + (e ? 1 : 0) + (f ? 1 : 0)+ (g ? 1 : 0);
// If you have more checkboxes on your form
// add more (box_ ? 1 : 0) 's separated by '+'

if (count > max) {
alert("Lo siento solo puedes seleccionar " + max + " opciones.");
obj.checked = false;
}
}
</script>
<input type="checkbox" name="opcion" id="ideacion" onClick="countChoices(this)">Ideación<br>
<input type="checkbox" name="opcion" id="organizacion" onClick="countChoices(this)">Organización de Procesos<br>
<input type="checkbox" name="opcion" id="factibilidad" onClick="countChoices(this)">Factibilidad<br>
<input type="checkbox" name="opcion" id="desarrollo" onClick="countChoices(this)">Desarrollo<br>
<input type="checkbox" name="opcion" id="escalamiento" onClick="countChoices(this)">Escalamiento<br>
<input type="checkbox" name="opcion" id="implementacion" onClick="countChoices(this)">Implementación<br>
<input type="checkbox" name="opcion" id="evaluacion" onClick="countChoices(this)">Evaluacón del Desempeño del Producto<br>
</div>

Añade tu respuesta

Haz clic para o