Ver Mensaje Individual
  #3 (permalink)  
Antiguo 29/10/2012, 10:15
stron1889
 
Fecha de Ingreso: octubre-2012
Mensajes: 12
Antigüedad: 11 años, 7 meses
Puntos: 0
Respuesta: permitir maximo checkbox por grupos

Si me equivoque al ponerlo quedaria asi

Código:
function validacion(obj) {
  limite=3;                  
  num=0;
  if (obj.checked) {    
    for (i=0; ele=obj.form.elements[i]; i++)
      if (ele.checked) num++;   
  if (num>limite)
    obj.checked=false;
  }
} 


function validaciona(obj) {
limitea=3;
 numa=0;                        
  if (obj.checked) {    
    for (a=0; elea=obj.form.elements[a]; a++)
      if (elea.checked) numa++;
  if (numa>limitea)
    obj.checked=false;
  }
}
Código:
<INPUT TYPE="checkbox" NAME="PREGUNTA9" VALUE="GNSS systems" onclick="at5n();onchange=validacion(this)"> GNSS systems
<INPUT TYPE="checkbox" NAME="PREGUNTA9" VALUE="Hyperspectral remote sensing" onclick="at5n();onchange=validacion(this)"> Hyperspectral remote sensing
<INPUT TYPE="checkbox" NAME="PREGUNTA9" VALUE="No deficiencies" onclick="at5n();onchange=validacion(this)"> No deficiencies
<INPUT TYPE="checkbox" NAME="PREGUNTA9" VALUE="Cartography" onclick="at5n();onchange=validacion(this)"> Cartography

2º grupo
<INPUT TYPE="checkbox" NAME="PREGUNTA10" VALUE="Surveying" onclick="at6n();onchange=validaciona(this)"> Surveying</p>
<INPUT TYPE="checkbox" NAME="PREGUNTA10" VALUE="Cadastre" onclick="at6n();onchange=validaciona(this)"> Cadastre
INPUT TYPE="checkbox" NAME="PREGUNTA10" VALUE="Civil works surveying" onclick="at6n();onchange=validaciona(this)"> Civil works surveying
<INPUT TYPE="checkbox" NAME="PREGUNTA10" VALUE="LiDAR" onclick="at6n();onchange=validaciona(this)"> LiDAR
y la verdad ahora que dices lo del nombre, creo que deberia de tener algo como PREGUNTA9-1, PREGUNTA9-2... ya que me gustaria almacenar en una base de datos los checked. ¿Como lo podria hacer con document.getElementsByName(name)?

Gracias