Ver Mensaje Individual
  #3 (permalink)  
Antiguo 04/06/2008, 04:22
sheilac
 
Fecha de Ingreso: abril-2007
Mensajes: 59
Antigüedad: 17 años, 10 meses
Puntos: 0
Respuesta: ejemplo check_form de caricatos

bien
muchas gracias por contestar
trate de adaptar este ejemplo a mi formulrio y anda barbaro solo que tengo ese problema
este es mi formulario principal donde hago la precarga de la imagen
PanelAgregarCont.php
el cual en elf ormulario llamo a mi funcion validar check form y comento la validar que tu utilizas ya que quiero validar todos los datos del formulrio y llamo a mi formulrio de listado , es la diferencia con tu codigo, de aqui voy a mi formulario listados,

Código PHP:
<? 
include_once('../includes/db.inc.php');
$bdsec = new db($host,$user,$pass);
$bdsec->db_connect();
$bdsec->db_select_db($db);

$bdsec->db_sql_select('*','secciones','1=1 and version ="espanol"',array('IdSeccion'=>'asc'),'');
 
$bdsec->db_execute_query();

?>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="description" content="">
<meta NAME="keywords" content="">

<script src="../js/swfobject.js" type="text/javascript"></script>

<script src="../js/funciones.js" type="text/javascript"></script>
<script type="text/javascript">
            function actuar(peso, anchura, altura)    {
                this.peso.value = peso;
                this.ancho.value = anchura;
                this.alto.value = altura;
            }

            function ini()    {
                document.forms.formu.actualizar = actuar;
                window.frames.ver.location.href = "previsor.php";
                   //document.img.ver.location.href="previsor.php";
                document.forms.formu.actualizar(0, 0, 0);

            }

            
            function limpiar()    {
                document.forms.formu.actualizar(0, 0, 0);
                f = document.getElementById("archivo");
                nuevoFile = document.createElement("input");
                nuevoFile.id = f.id;
                nuevoFile.type = "file";
                nuevoFile.name = "archivo";
                nuevoFile.value = "";
                nuevoFile.onchange = f.onchange;
                nodoPadre = f.parentNode;
                nodoSiguiente = f.nextSibling;
                nodoPadre.removeChild(f);
                (nodoSiguiente == null) ? nodoPadre.appendChild(nuevoFile):
                    nodoPadre.insertBefore(nuevoFile, nodoSiguiente);
            }

            function checkear(f)    {
                function no_prever() {
                    alert("El fichero seleccionado no es válido...");
                    limpiar();
                }
                function prever() {
                    var campos = new Array("peso", "alto", "ancho");
                    for (i = 0, total = campos.length; i < total; i ++)
                        f.form[campos[i]].disabled = false;
                    actionActual = f.form.action;
                    targetActual = f.form.target;
                    f.form.action = "previsor.php";
                    f.form.target = "ver";
                    f.form.submit();
                    for (i = 0, total = campos.length; i < total; i ++)
                        f.form[campos[i]].disabled = true;
                    f.form.action = actionActual;
                    f.form.target = targetActual;
                }

                (/\.(gif|jpg|png|ico|bmp)$/i.test(f.value)) ? prever() : no_prever();
            }

            function datosImagen(peso, ancho, alto, error)    {
                function mostrar_error()    {
                    enviar = false;                    
                    mensaje = "Ha habido un error (error nº " + error + "):";
                    if (error % 2 == 1) // tipo incorrecto
                        mensaje += "\nel fichero no es válido";
                    error = parseInt(error / 2);                    
                    limpiar();
                }
                if (error == 0)
                    document.forms.formu.actualizar(peso, ancho, alto);
                else
                    mostrar_error();
            }
            
            
function checkForm()
            {
              var exp = /^[\+\-]{0,1}[0-9]+[\.]{0,1}[0-9]*$/;
              var re_int = /^(?:\+|-)?\d+$/;
                
              fotoprincipal=document.getElementById('fotoprincipal').value;
              descripcion=document.getElementById('descripcion').value; 
            
              titulo=document.getElementById('titulo').value;
            
              if (fotoprincipal==''){
                alert('Debe ingresar la foto !');
                document.getElementById('fotoprincipal').focus();
                return false;
              }
            
              if(descripcion==''){    
                  alert('Debe ingresar la descripicion !');
                  document.getElementById('descripcion').focus();
                  return false;
                }
            
              if(titulo==''){    
                  alert('Debe ingresar el titulo!');
                  document.getElementById('titulo').focus();
                  return false;
              } 
              return true;
}
</SCRIPT>

<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body onLoad="MM_preloadImages('images/3kzOn.gif'),ini()">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" class="BackFoot">
  <tr>
    <td height="170" align="center" valign="top" class="BackPanel"><table width="780" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left"><img src="../images/HeadPanel.jpg" width="643" height="116"></td>
        <td width="51" valign="top"><a href="PanelControl.html"><img src="../images/BtnCas.gif" width="51" height="34" border="0"></a><br>
          <a href="ingles/PanelControl.html"><img src="../images/BtnEng.gif" width="51" height="34" border="0"></a></td>
      </tr>
    </table>
    </td>
  </tr>
  
  <tr>
    <td height="77" valign="top"><table width="780" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="200" height="10" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="TxtMenu">
          <tr>
            <td height="36" align="left" valign="middle">&nbsp;</td>
          </tr>        
          <tr>
            <td height="22" align="left" valign="middle" class="MenuTd"><img src="../images/BullOn.gif" width="7" height="7" />Agregar Contenido</td>
          </tr>
         
         
        </table></td>
        <td width="30">&nbsp;</td>
        <td valign="top">
          <form name="formu" id="formu" method="post" action="PanelAdmCont.php"  onSubmit="return checkForm();"   enctype='multipart/form-data'>
     <? if($rowsec $bdsec->get_next_row()){?>
    
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="36" class="TxtTitulo">Panel de Control </td>
          </tr>
          <tr></tr>
          <tr>
            <td height="15" class="TxtHome">&nbsp;</td>
          </tr>
          <tr>
            <td height="15" class="TxtHome"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="TxtHome">
              <tr>
                <td width="150" height="20" valign="middle">Selecciones una Secci&oacute;n</td>
                <td valign="middle"> <select name="id_seccion" id="id_seccion"  class="select-panel">
            <? 
                                $cont
=0;
                                while(
$rowsec){
                                
?>
                        <option value="<? echo $rowsec['IdSeccion'];?><? if($cont==0) echo "selected";?>><? echo $rowsec['Name'];?></option>
                        <? 
                                $rowsec 
$bdsec->get_next_row();
                                
$cont++;
                                }
                                
?>
                      </select>
                      </td>
              </tr>

            </table></td>
          </tr>
          <tr>
            <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="TxtHome">
              <tr class="BordePanel">
                <td width="150" height="27" valign="middle" class="BordePanel">&nbsp;</td>
                <td valign="middle">&nbsp;</td>
                </tr>
              <tr class="BordePanel">
                <td height="60" valign="middle" >Cargar  im&aacute;gen <br>
                  270 x 204 px.</td>
                <td valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr class="BordePanelZero">
                  <!--aqui utilizo el frame de la imagen-->
                    <td width="270"  align="left" valign="bottom"><iframe   id="ver" frameborder="0"   name="ver" align="bottom" style=" width: 270px; height: 204px;"></iframe></td>
                    <td align="left" valign="bottom"><input type="file" name="fotoprincipal" id="fotoprincipal" src="previsor.php"  onchange="this.form.target = checkear(this)"  ></input> 
                            <input type="hidden" readonly name="peso" value="0" />
                            <input type="hidden" readonly name="ancho" value="0" />                            
                            <input type="hidden" readonly name="alto" value="0" /></td>
                  </tr>
                </table></td>
                </tr>
              <tr class="BordePanel">
                <td height="20" valign="middle">Descripci&oacute;n</td>
                <td valign="middle"><input name="descripcion" type="text" class="input Panel" id="descripcion"/></td>
                </tr>
              <tr class="BordePanel">
                <td height="20" valign="middle">T&iacute;tulo</td>
                <td valign="middle"><input name="titulo" type="text" class="input Panel" id="titulo"/></td>
                </tr>
              <tr class="BordePanel">
                <td height="20" valign="top">Texto  Principal</td>
                <td valign="middle">    <textarea name="cuerpo" rows="30" cols="44" id="cuerpo" class="input-txt"></textarea>          
       </td>
                </tr>
              
              <tr>
                <td height="40" valign="middle">&nbsp;</td>
                <td valign="middle"><input type="hidden" value="1" name="add"><a href="javascript:if(checkForm()){formu.submit();}"><img src="../images/BtnAceptar.gif" width="33" height="20" border="0"></a></td>
                </tr>
                
            </table>
            
            </td>
          </tr>
          <tr></tr>     
        </table>
        
        <? }?>
    </form>
        </td>
        </tr>
    </table></td>
  </tr>
  
  <tr>
    <td height="100" valign="bottom"><table width="780" height="50" border="0" align="center" cellpadding="0" cellspacing="0" class="TxtFoot">
     

    </table></td>
  </tr>
</table>
</body>
</html>