Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/12/2009, 04:03
quimfv
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 10 meses
Puntos: 574
Respuesta: Validar que se seleccione al menos un option

Código HTML:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <title>Documento sin t&iacute;tulo</title>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  4. <script language="JavaScript" type="text/JavaScript">
  5. function valida(){
  6. var seleccionado=false;
  7.     for (i=0;i<4;i++){
  8.         if (document.getElementById("opl10"+i).checked==true){
  9.             seleccionado=true;
  10.         }
  11.     }
  12.     if (seleccionado){
  13.         document.getElementById("segundalinea").style.display="block";
  14.     }else{
  15.         document.getElementById("segundalinea").style.display="none";
  16.         for (i=0;i<4;i++){
  17.             document.getElementById("opl20"+i).checked=false;
  18.         }
  19.     }
  20. }
  21. </head>
  22. <table width="100%" border="1" cellspacing="0" cellpadding="0">
  23.   <tr>
  24.     <td><input name="opl100" type="checkbox" id="opl100" value="" onChange="valida()"></td>
  25.     <td><input name="opl101" type="checkbox" id="opl101" value="" onChange="valida()"></td>
  26.     <td><input name="opl102" type="checkbox" id="opl102" value="" onChange="valida()"></td>
  27.     <td><input name="opl103" type="checkbox" id="opl103" value="" onChange="valida()"></td>
  28.   </tr>
  29. <span id="segundalinea" style="display:none">
  30. <table width="100%" border="1" cellspacing="0" cellpadding="0">
  31.   <tr>
  32.     <td><input name="opl200" type="checkbox" id="opl200" value=""></td>
  33.     <td><input name="opl201" type="checkbox" id="opl201" value=""></td>
  34.     <td><input name="opl202" type="checkbox" id="opl202" value=""></td>
  35.     <td><input name="opl203" type="checkbox" id="opl203" value=""></td>
  36.   </tr>
  37. </span>
  38. </body>
  39. </html>

Una opción... hay muchas mas....

Quim