Ver Mensaje Individual
  #3 (permalink)  
Antiguo 16/06/2009, 10:26
andresito12_19
 
Fecha de Ingreso: noviembre-2008
Mensajes: 80
Antigüedad: 16 años, 4 meses
Puntos: 1
Respuesta: problema con input radio

Cita:
Iniciado por David el Grande Ver Mensaje
Muestra el código de la validación y si no es muy largo también el código del formulario completo; ya que de la forma como está debería funcionar.
este es la funcion de validacion
Código PHP:
function valida_ing(form){
      var 
Formulario document.getElementById(form);
      var 
num=Formulario.elements.length;
      var 
nc="";
      for (var 
i=0i<=num-1i++) {
          if (
Formulario.elements[i].value==''){
           
nc+=Formulario.elements[i].name+' Es un valor requerido. \n';
           }
         }
   if (
nc==''){
        
document.forms[0].submit();
    }
    else {
    
alert('Por Favor Corrige los siguintes campos:\n'+nc);
    }
   } 
y este es el codigo del formulario
Código PHP:
<form name="form1" method="post" action="javascript:enviarFormulario('../dao/php_estudiante/nuevo.php','form1');">
   <table width="700">
    <caption align="top">
      <span class="Estilo4"><img src="../Imagenes/nuevo_est.png" width="500" height="60" border="0"></span>
    </caption>
    <tr><th colspan="2"><hr></th></tr>
    <tr><th>
    <table align="left">
    <tr>
      <th align="right">Identificacion</th>
      <td align="left"><input name="id_est" type="text" value="<?php echo "".$_POST['id_est']; ?>"  onKeyPress="return acceptNum(event)"></td>
    </tr>
    <tr>
      <th align="right">Nombres</th>
      <td align="left"><input name="nom_est" size="40" type="text" value="<?php echo"".$_POST['nom_est'];?>" onKeyUp="this.value=this.value.toUpperCase();" id="nom_adm"></td>
    </tr>
    <tr>
      <th align="right">Direccion</th>
      <td align="left"><input name="dir_est" type="text" value="<?php echo"".$_POST['dir_est'];?>" ></td>
    </tr>
    <tr>
      <th align="right">Telefono</th>
      <td align="left"><input name="tel_est" type="text" value="<?php echo"".$_POST['tel_est'];?>"></td>
    </tr>
    <tr>
      <th align="right">Nacionalidad</th>
      <td align="left"><input name="nac_est" type="text" value="<?php echo"".$_POST['tel_est'];?>"></td>
    </tr>
    <tr>
      <th align="right">Sexo:</th>
      <th align="left">F<input name="sexo" type="radio" value="Femenino">
                       M<input name="sexo" type="radio" value="Masculino">
      </th>
    </tr>
    <tr>
      <th align="right">Tipo de Sangre</th>
      <th align="left"><input name="tps" size="3" type="text" value="<?php echo"".$_POST['tps'];?>"></th>
    </tr>
    <tr>
      <th align="right">Estudiante:</th>
      <th align="left">Trasladado<input name="esta" type="radio" value="Trasladado">
      Continuo<input name="esta" type="radio" value="Continuo">Repitente<input name="esta" type="radio" value="Repitente"></th>
      </tr>
    </table></th>
    <th>
    <table>
    <tr>
      <th align="right">Edad</th>
      <td align="left"><input name="edad_est" size="3" type="text" value="<?php echo"".$_POST['edad_est'];?>" onKeyPress="return acceptNum(event)"></td>
    </tr>
    <tr>
      <th align="right">Fecha de Nacimiento(dd/mm/aaaa)</th>
      <td align="left"><input name="fec_nac" type="text" value="<?php echo"".$_POST['fec_nac'];?>" onblur="valFecha(this)"></td>
    </tr>
    <tr>
      <th align="right"># de Personas en casa</th>
      <td align="left"><input name="per_cas" size="3" type="text" value="<?php echo"".$_POST['per_cas'];?>" onKeyPress="return acceptNum(event)"></td>
    </tr>
    <tr>
      <th align="right">Estrato</th>
      <td align="left"><input name="est" type="text" size="3" value="<?php echo"".$_POST['est'];?>" onKeyPress="return acceptNum(event)"></td>
    </tr>
    <tr>
      <th align="right">Grupo Etnico</th>
      <th align="left"><select name="gru_et" >
     <option  value="<?php echo "".$_POST['gru_et']; ?>" selected="<?php echo "".$_POST['gru_et']; ?>"><?php echo "".$_POST['gru_et']; ?></option>
      <option value="Gitano">Gitano</option>
     <option value="Indigena">Indigena</option>
     <option value="AfroColombiano">AfroColombiano</option>
    </select></th>
    </tr>
    <tr>
      <th align="right">Grado:</th>
      <th align="left"><select name="grado" >
     <option  value="<?php echo "".$_POST['grado']; ?>" selected="<?php echo "".$_POST['grado']; ?>"><?php echo "".$_POST['grado']; ?></option>
      <?php
     $mat
=new ConsultasDAO();
     
$con=$mat->db->consulta("*",'grado',$cond,"");
     
$num=pg_num_rows $con );
     if (
$num>0) {
     while(@
$fila=pg_fetch_array($mat->db->consulta)){
               
?>
      <option value="<?php echo"".$fila["id_grado"];?>"><?php echo"".$fila["nom_grado"];?></option>
  <?php }} ?>
    </select></th>
    </tr>
    <tr>
      <th align="right">Vive con Papa:</th>
      <th align="left">Si<input name="viv_pap" type="radio" value="si">No<input name="viv_pap" type="radio" value="no"></th>
    </tr>
    <tr>
      <th align="right">Vive con Mama:</th>
      <th align="left">Si<input name="viv_mam" type="radio" value="si">No<input name="viv_mam" type="radio" value="no"></th>
    </tr>

  </table></th>
    </tr>
    <tr><th colspan="2"><hr></th></tr>
  </table>
  <BR>
  <table width="700" border="1" align="center">
    <caption align="top" class="Estilo5">
    <span class="Estilo4">INGRESO DE DATOS DE LOS PADRES</span>
    </caption>
    <tr>
      <th class="celda" align="center">DATOS DEL PADRE</th>
      <th class="celda" align="center">DATOS DE LA MADRE</th>
    </tr>
    <tr>
      <th align="center">
      Esta Vivo: <input name="ta_viv_pap" type="radio" value="si" Onclick="vertabla('tablap','');" >Si <input name="ta_viv_pap" type="radio" Onclick="vertabla('tablap','none');" value="no">No
         <table id="tablap" style="display:none">
    <tr>
      <th align="right">Identificacion</th>
      <td align="left"><input name="id_pap" type="text" value="<?php echo "".$_POST['id_pap']; ?>"  onKeyPress="return acceptNum(event)"></td>
    </tr>
    <tr>
      <th align="right">Nombres</th>
      <td align="left"><input name="nom_pap" size="40" type="text" value="<?php echo"".$_POST['nom_pap'];?>" onKeyUp="this.value=this.value.toUpperCase();" id="nom_adm"></td>
    </tr>
    <tr>
      <th align="right">Direccion</th>
      <td align="left"><input name="dir_pap" type="text" value="<?php echo"".$_POST['dir_pap'];?>" ></td>
    </tr>
    <tr>
      <th align="right">Telefono</th>
      <td align="left"><input name="tel_pap" type="text" value="<?php echo"".$_POST['tel_pap'];?>"></td>
    </tr>
    <tr>
      <th align="right">Profesion</th>
      <td align="left"><input name="prof_pap" type="text" value="<?php echo"".$_POST['prof_pap'];?>"></td>
    </tr>
    </tr></table></th>
      <th align="center">
      Esta Viva: <input name="ta_viv_ma" type="radio" value="si" Onclick="vertabla('tablam','');" >Si <input name="ta_viv_ma" type="radio" Onclick="vertabla('tablam','none');" value="no">No
         <table id="tablam" style="display:none">
    <tr>
      <th align="right">Identificacion</th>
      <td align="left"><input name="id_mam" type="text" value="<?php echo "".$_POST['id_mam']; ?>"  onKeyPress="return acceptNum(event)"></td>
    </tr>
    <tr>
      <th align="right">Nombres</th>
      <td align="left"><input name="nom_mam" size="40" type="text" value="<?php echo"".$_POST['nom_mam'];?>" onKeyUp="this.value=this.value.toUpperCase();" id="nom_adm"></td>
    </tr>
    <tr>
      <th align="right">Direccion</th>
      <td align="left"><input name="dir_mam" type="text" value="<?php echo"".$_POST['dir_mam'];?>" ></td>
    </tr>
    <tr>
      <th align="right">Telefono</th>
      <td align="left"><input name="tel_mam" type="text" value="<?php echo"".$_POST['tel_mam'];?>"></td>
    </tr>
    <tr>
      <th align="right">Profesion</th>
      <td align="left"><input name="prof_mam" type="text" value="<?php echo"".$_POST['prof_mam'];?>"></td>
    </tr>
    </table></th>
    </tr>
    </table>
  <table>
  <tr>
      <th colspan="8" scope="row">
      <input type="hidden" name="ing" value="no">
         <a class="enlace" href="#" onClick="valida_est('form1')" ><img src="../Imagenes/botong.png" width="112" height="38" border="0"></a>
        <a class="enlace" href="#" onClick="document.forms.form1.reset();return false"><img src="../Imagenes/cancelar.png" width="112" height="38" border="0"></a>
     </th>
    </tr>
      </table>
  <br>
  </div>
</form>