Foros del Web » Programando para Internet » Javascript »

Problemas con onload y onsumit

Estas en el tema de Problemas con onload y onsumit en el foro de Javascript en Foros del Web. hola tengo un formulario donde cargo los estilos en del form en el body con la funcion onload, ademas de esto valido el formulario con ...
  #1 (permalink)  
Antiguo 16/06/2010, 10:08
Avatar de wladtepes  
Fecha de Ingreso: febrero-2008
Mensajes: 140
Antigüedad: 16 años, 3 meses
Puntos: 0
Exclamación Problemas con onload y onsumit

hola tengo un formulario donde cargo los estilos en del form en el body con la funcion onload, ademas de esto valido el formulario con la funcion onSumit

pero al tener la funcion onload dentro del body no me valida el formulario


de antemano gracias
  #2 (permalink)  
Antiguo 16/06/2010, 12:16
Avatar de yoyoyo82  
Fecha de Ingreso: julio-2009
Ubicación: Springfield
Mensajes: 159
Antigüedad: 14 años, 9 meses
Puntos: 1
Respuesta: Problemas con onload y onsumit

si pones el codigo quisa te pudiera ayudar
  #3 (permalink)  
Antiguo 16/06/2010, 13:28
Avatar de wladtepes  
Fecha de Ingreso: febrero-2008
Mensajes: 140
Antigüedad: 16 años, 3 meses
Puntos: 0
Respuesta: Problemas con onload y onsumit

ESE ES EL CODIGO

Código PHP:
<?Php 
include("funciones.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Promoservice</title>
<?php 
estilo_promo
();
?>
   
    
<script  type="application/javascript"> 
function valida(form1)
{

if (form1.nombre.value =="" )
{
alert("Ingrese un nombre");
form1.nombre.focus();
return false;
}

if (form1.empresa.value =="" )
{
alert("Ingrese el nombre de la empresa");
form1.empresa.focus();
return false;
}

if (form1.mail.value =="" )
{
alert("Ingrese Email");
form1.mail.focus();
return false;
}

if (form1.telefono.value =="" )
{
alert("Ingrese Telefono");
form1.telefono.focus();
return false;
}
if (form1.comentarios.value =="" )
{
alert("Ingrese un Comentario");
form1.comentarios.focus();
return false;
}

form.submit();

}
</script>

 <script type="text/javascript" src="css/prettyForms.js"></script>
    <link rel="stylesheet" href="css/prettyForms.css" type="text/css" media="screen" />
</head>

<body  bgcolor="#CCCCCC" leftmargin="0" topmargin="0" bottommargin="0" onload="prettyForms()">
<center>
<div class="body">
<br>
<table  border="0" cellpadding="0" cellspacing="0">

<!-- INICIO PIMER BLOQUE -->
 <tr>
 <td> 
         <table border="0" align="center" cellpadding="0" cellspacing="0" >
         <tr>
          <?php bloque_uno_1(); ?>
          </tr>
          <tr>
          <td align="left" colspan="3">
        <table  border="0" align="center" cellpadding="0" cellspacing="0">
        <tr bgcolor="#FFFFFF">
        <td >
          <span class="style2">
          <?Php swf_contactanos(); ?>
          </span>        </td>
        <td width="460">
        <table width="451" height="370" border="0" cellpadding="0" cellspacing="0">
        <tr>
        <td width="10" class="style2"></td>
    <td   colspan="3"><?php imagen_promo_blanco(); ?></td>
        </tr>
        <tr>
        <td  height="248" colspan="5"  align="center">
        
        
        <table border="0" cellpadding="0" cellspacing="0">
           
           
      <form action="mail/EnviarCorreo.php"  method="get" name="form1" id="form1" onSubmit="return valida(this);" >

           <tr align="left">
           <td width="77" >Nombres</td>
           <td width="191"> <input name="nombre"  id="nombre" type="text" ></td></tr>
           <tr align="left"><td height="23">Empresa</td>
           <td> <input name="empresa" id="empresa"type="text" ></td></tr>
           <tr align="left"><td>E-mail</td><td><input name="mail"  id="mail" type="text" ></td></tr>
           <tr align="left"><td>Telefono</td><td><input name="telefono" id="telefono" type="text"></td></tr>
           <tr><td valign="top">Comentarios</td>
           <td><textarea name="comentarios" rows="5" cols="35" ></textarea></td>
           </tr>
           <tr align="left"><td> <input name="action" type="hidden" value="send"></td><td><input name="Enviar" type="submit" value="Enviar"></td></tr>        </form>
       </table></td>
        </tr>
        <tr><td colspan="5">
    
    <table  border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="120"></td>
    
   <td>

   <?Php swf_boton_quienesSomos();?>   </td>

    <td >
    <?Php  swf_boton_servicios();?></td>
    <td >
    <?Php swf_boton_clientes(); ?></td>
      <td >
    <?Php swf_boton_contacte(); ?></td>
    </tr>
    </table>
    
    </td>
    </tr>
    </table>    </td>
    </tr>
    </table> 
         </td></tr>
   </table>
    </td>
  </tr>
  
  <!-- FIN PRIMER BLOQUE -->
  <!-- INICIO SEGUNDO BLOQUE -->
  <tr >
 <td  align="center"><?php swf_tira()?>  </td>
  </tr>
    <!-- FIN SEGUNDO BLOQUE -->
    <!-- INICIO TERCER BLOQUE -->
  <tr  align="center">
  <td>
 <?php bloque_tres();?>
    </td>
  </tr>
    <!-- FIN TERCER BLOQUE --->
</table>
</div>
</center>
<br>
</body>
</html>
<?php

?>
  #4 (permalink)  
Antiguo 16/06/2010, 15:03
Avatar de yoyoyo82  
Fecha de Ingreso: julio-2009
Ubicación: Springfield
Mensajes: 159
Antigüedad: 14 años, 9 meses
Puntos: 1
Respuesta: Problemas con onload y onsumit

una pregunta en que parte esta tu funcion prettyForms() supongo que es la que contiene los estilos
  #5 (permalink)  
Antiguo 16/06/2010, 15:27
Avatar de wladtepes  
Fecha de Ingreso: febrero-2008
Mensajes: 140
Antigüedad: 16 años, 3 meses
Puntos: 0
Respuesta: Problemas con onload y onsumit

Código PHP:
function prettyForms(){
        
fixTextBoxes();
        
fixTextareas();
        
fixSubmits();
    }
    
    function 
appendParentsTo(currItem){
        
//create the divs
        
tl document.createElement("div");
        
br document.createElement("div");
        
bl document.createElement("div");
        
tr document.createElement("div");

        if(
document.all){                            //IE
            //give them the proper class
            
tl.className="frmShdwTopLt";
            
br.className="frmShdwBottomRt";
            
bl.className="frmShdwBottomLt";
            
tr.className="frmShdwTopRt";
            
//insert the top level div
            
t1=currItem.insertAdjacentElement("BeforeBegin",tl);
            
            
        }else{                                        
//FFX
            //give them the proper class
            
tl.setAttribute("class""frmShdwTopLt");
            
br.setAttribute("class""frmShdwBottomRt");
            
bl.setAttribute("class""frmShdwBottomLt");
            
tr.setAttribute("class""frmShdwTopRt");
            
inputParent currItem.parentNode;
            
//insert the top level div
            
tl inputParent.insertBefore(tlcurrItem);
        }
        
        
//append children
        
br tl.appendChild(br);
        
bl br.appendChild(bl);
        
tr bl.appendChild(tr);
        
//move input to child of divs
        
tr.appendChild(currItem);
    }


    
//apply look to text boxes
    
function fixTextBoxes(){
        
inputs document.getElementsByTagName("input");
        for(
i=0;i<inputs.length;i++){
            if(
inputs[i].type=="text"){
                
appendParentsTo(inputs[i]);
            }
        }
    }
    
    
//apply look to textareas
    
function fixTextareas(){
        
textareas document.getElementsByTagName("textarea")
        for(
i=0;i<textareas.length;i++){
            
appendParentsTo(textareas[i]);
        }
    }
    
    
    
//apply look to submit buttons
    
function fixSubmits(){
        
inputs document.getElementsByTagName("input");
        for(
i=0;i<inputs.length;i++){
            if(
inputs[i].type=="submit"){
                
appendParentsTo(inputs[i]);
                
inputs[i].className="frmShdwSubmit";
            }
        }
    }
    

    
    

    
    
    
//function to trigger events that are built into the form elements that have been hidden
    
function triggerEvent(objevt){
        if(
document.all){
            if(
evt=="click"){
                
res obj.fireEvent("onclick");
            }else if(
evt=="change"){
                
res obj.fireEvent("onchange");
            }
        }else{
            
//NOTE - in the mozilla event model, I am cancelling the bubbleUp!  (1st false)
            // this is needed to prevent odd interaction, but could cause other issues!
            
if(evt=="click"){
                
mouseEvent document.createEvent('MouseEvents');
                
mouseEvent.initMouseEvent('click',true,true,window,1,0,0,0,0,false,false,false,false,0,null);
                
obj.dispatchEvent(mouseEvent); 
            }else if(
evt=="change"){
                
mouseEvent document.createEvent('HTMLEvents');
                
mouseEvent.initEvent('change',true,true,window,1,0,0,0,0,false,false,false,false,0,null);
                
obj.dispatchEvent(mouseEvent);
            }
        }
    } 
  #6 (permalink)  
Antiguo 16/06/2010, 15:37
Avatar de yoyoyo82  
Fecha de Ingreso: julio-2009
Ubicación: Springfield
Mensajes: 159
Antigüedad: 14 años, 9 meses
Puntos: 1
Respuesta: Problemas con onload y onsumit

mira yo para cargar estilos solo utilizo
<script type="text/javascript" src="css/prettyForms.js"></script>
cual es la finalidad del
<onload="prettyForms()">
si quieres cargar los estilos para el form de esa manera, entonces llama las 2 funciones en el form, aunque como te comento basta con la primera etiqueta para cargar los estilos
  #7 (permalink)  
Antiguo 16/06/2010, 15:49
Avatar de wladtepes  
Fecha de Ingreso: febrero-2008
Mensajes: 140
Antigüedad: 16 años, 3 meses
Puntos: 0
Respuesta: Problemas con onload y onsumit

por la razon de que cargo los estilos nuevamente en el onload es por que necesito que los bordes de los textbox esten con las esquinas redondeadas ,pero esto me trae problemas con las validaciones

Etiquetas: onload
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:26.