Foros del Web » Programando para Internet » Javascript »

problema con hacer un submit

Estas en el tema de problema con hacer un submit en el foro de Javascript en Foros del Web. Hola copañeros este es mi codigo y lo que pasa con el que no me esta haciendo el submit para que me aumente el valor ...
  #1 (permalink)  
Antiguo 20/11/2006, 08:21
Avatar de dontripi  
Fecha de Ingreso: enero-2006
Mensajes: 240
Antigüedad: 18 años, 3 meses
Puntos: 1
problema con hacer un submit

Hola copañeros este es mi codigo y lo que pasa con el que no me esta haciendo el submit para que me aumente el valor de $inicio y me entre en el if para poder mostrar los valores que tengo ahí dentro.

Código HTML:
<!doctype html public "-//W3C//DTD HTML 4.0 //EN"> 
<html>
<head>
       <title>Captura de Presupuesto</title>
       <link type="text/css" rel="stylesheet" href="style.css">

</head>
<body>
<?php
echo "<center>";
             echo $inicio; //aqui imprimo inicio para ver si asignoel nuevo valor
             echo "<div class=\"informacion\">";
             echo "<h3>PRESUPUESTO</h3>";
             echo "</div>";
        	  echo "</center>";
        	  ?>
            <br>
            <br>
    <form method="post" name="frmadprespro" action="../programa/index.php">
            <table width="100%">
				   <tr>
				        <td>
                      Sucursal:
                    </td>
                    <td>
                      <select name= "slsucursal" style="width:250"  onblur="CONSULTA('frmadprespro')">
                        <option></option>
                        <option>Armenia</option>

                      </select>
                  </td>
                  
                  </tr>
                  </table>
                  
                  <br>
             <?php
             if ($inicio == 1)  //begin de if $inicio == 1 en comienzo tabla
             {
             ?>

             <table width="100%">

                  <tr>


                    <td style="border:none" align="center" bgcolor="">
                      <font size="3">
                        #
                      </font>
                    </td>

                    <td colspan="2" style="border:none" align="center" bgcolor="">
                      <font size="3">
                        Producto
                      </font>
                    </td>



                    <td style="border:none" align="center" bgcolor="">
                      <font size="3">
                        Unidad
                      </font>
                    </td>

                    <td style="border:none" align="center" bgcolor="">
                      <font size="3">
                        Valor
                      </font>
                    </td>



<?php



                                           
      }    //end if $inicio  == 1 en el comienzo de la tabla
                
?>


                   <input type="hidden" name="pasa1" value="0">
                   <input type="hidden" name="inicio" value="0">
</body>
</form>


<script>

 function CONSULTA(form)
			  {
			  
                     frm.inicio.value = 1;
                     alert(frm.inicio.value);
                     document.forms[form].submit();

			  }

</script>

</html> 
  #2 (permalink)  
Antiguo 20/11/2006, 09:15
Avatar de caricatos
Moderador
 
Fecha de Ingreso: abril-2002
Ubicación: Torremolinos (Málaga)
Mensajes: 19.607
Antigüedad: 22 años
Puntos: 1284
Hola:

Es difícil ver el código cuando está mezclado con php... deberías mostrar solo lo que recibe el navegador (ver código fuente)... pero tu función CONSULTA(form) tienes unos objetos "frm" que no se ven declarados...

Y un consejo para tus formularios es que pongas para su envío botones del tipo submit... son reglas muy básica.

Saludos
__________________
Por favor:
No hagan preguntas de temas de foros en mensajes privados... no las respondo
  #3 (permalink)  
Antiguo 20/11/2006, 09:33
Avatar de dontripi  
Fecha de Ingreso: enero-2006
Mensajes: 240
Antigüedad: 18 años, 3 meses
Puntos: 1
solo HTML

Perdón aqui esta el codigo en solo HTML, no se que pasa la verdad, te agradecería quelo revisaras y me dijeras cual es el problema.




Código HTML:
<!doctype html public "-//W3C//DTD HTML 4.0 //EN"> 
<html>
<head>
       <title>Captura de Presupuesto</title>
       <link type="text/css" rel="stylesheet" href="style.css">

</head>
<body>
<center><div class="informacion"><h3>CARGAR PRESUPUESTO</h3></div></center> <br>
            <br>
    <form method="post" name="frmadprespro" action="index.php">

            <table width="50%">
				   <tr>
				        <td>
                      Sucursal:
                    </td>
                    <td>
                      <select name=" slsucursal" style="width:250"  onblur="CONSULTA('frmadprespro')">
                        <option></option>
                        <option>Armenia</option>

                      </select>
                  </td>
                  
                  </tr>
                  </table>
                  
                  <br>
             
             <table width="100%">

                  <tr>

                    <td  align="center" bgcolor="">
                      <font size="3">
                        #
                      </font>
                    </td>

                    <td colspan="2" align="center" bgcolor="">
                      <font size="3">
                        Producto
                      </font>

                    </td>



                    <td align="center" bgcolor="">
                      <font size="3">
                        Unidad
                      </font>
                    </td>

                    <td  align="center" bgcolor="">

                      <font size="3">
                        Valor
                      </font>
                    </td>
                    
                    
                    <td  align="center" bgcolor="">
                      <font size="3">
                        Enero
                      </font>
                    </td>
                    
                    <td  align="center" bgcolor="">

                      <font size="3">
                        Febrero
                      </font>
                    </td>
                    
                    <td  align="center" bgcolor="">
                      <font size="3">
                        Marzo
                      </font>
                    </td>
                    
                    <td align="center" bgcolor="">

                      <font size="3">
                        Abril
                      </font>
                    </td>
                    
                    <td align="center" bgcolor="">
                      <font size="3">
                        Mayo
                      </font>
                    </td>
                    
                    <td align="center" bgcolor="">

                      <font size="3">
                        Junio
                      </font>
                    </td>
                    
                    <td align="center" bgcolor="">
                      <font size="3">
                        Julio
                      </font>
                    </td>
                    
                    <td align="center" bgcolor="">

                      <font size="3">
                        Agosto
                      </font>
                    </td>
                    
                    <td align="center" bgcolor="">
                      <font size="3">
                        Septiembre
                      </font>
                    </td>
                    
                    <td align="center" bgcolor="">

                      <font size="3">
                        Octubre
                      </font>
                    </td>
                    
                    <td align="center" bgcolor="">
                      <font size="3">
                        Noviembre
                      </font>
                    </td>
                    
                    <td align="center" bgcolor="">

                      <font size="3">
                        Diciembre
                      </font>
                    </td>




                   <input type="hidden" name="pasa1" value="0">
                   <input type="hidden" name="inicio" value="0">
</body>
</form>


<script>

 function CONSULTA(form)
			  {
			  //frm.flet.value = 1;
			  //frm.costo.value = 0;
              alert("hoLA");
              frm.inicio.value = 1;
              document.forms[form].submit();

			  }

</script>

</html> 
  #4 (permalink)  
Antiguo 20/11/2006, 16:10
Avatar de dontripi  
Fecha de Ingreso: enero-2006
Mensajes: 240
Antigüedad: 18 años, 3 meses
Puntos: 1
por que me sale este error

hola compañeros lo que pasa es que me sale que frm no esta definido no se que esto, yo soy un poco nuevo en esto del javascript, la verdad no se que hacer o como definir este frm, el codigo lo voy a poner de nuevo a continuacion, por que la verdad necesito esto muy urgente.


Por favor ayudenme con esto la verdad no se que mas hacer, que eslo que hay que definir y como.


Gracias de antemano.



Código HTML:
<!doctype html public "-//W3C//DTD HTML 4.0 //EN"> 
<html>
<head>
       <title>Captura de Presupuesto</title>
       <link type="text/css" rel="stylesheet" href="style.css">
        <script language="javascript" src="validar.js"></script></head>
<body>
<center><div class="informacion"><h3>CARGAR PRESUPUESTO</h3></div></center> <br>
            <br>

    <form method="post" name="frmadprespro" action="index.php">
            <table width="50%">
				   <tr>
				        <td>
                      Sucursal:
                    </td>
                    <td>
                      <select name=" slsucursal" style="width:250"  onblur="CONSULTA('frmadprespro')">
                        <option></option>

                        <option>Armenia</option>

                      </select>
                  </td>
                  
                  </tr>
                  </table>
                  
                  <br>
             
             <table width="100%">

                  <tr>


                    <td  align="center" bgcolor="">
                      <font size="3">
                        #
                      </font>
                    </td>

                    <td colspan="2" align="center" bgcolor="">
                      <font size="3">

                        Producto
                      </font>
                    </td>



                    <td align="center" bgcolor="">
                      <font size="3">
                        Unidad
                      </font>
                    </td>

                    <td  align="center" bgcolor="">
                      <font size="3">
                        Valor
                      </font>
                    </td>
                    
                    
                    <td  align="center" bgcolor="">
                      <font size="3">
                        Enero
                      </font>

                    </td>
                    
                    <td  align="center" bgcolor="">
                      <font size="3">
                        Febrero
                      </font>
                    </td>
                    
                    <td  align="center" bgcolor="">
                      <font size="3">
                        Marzo
                      </font>

                    </td>
                    
                    <td align="center" bgcolor="">
                      <font size="3">
                        Abril
                      </font>
                    </td>
                    
                    <td align="center" bgcolor="">
                      <font size="3">
                        Mayo
                      </font>

                    </td>
                    
                    <td align="center" bgcolor="">
                      <font size="3">
                        Junio
                      </font>
                    </td>
                    
                    <td align="center" bgcolor="">
                      <font size="3">
                        Julio
                      </font>

                    </td>
                    
                    <td align="center" bgcolor="">
                      <font size="3">
                        Agosto
                      </font>
                    </td>
                    
                    <td align="center" bgcolor="">
                      <font size="3">
                        Septiembre
                      </font>

                    </td>
                    
                    <td align="center" bgcolor="">
                      <font size="3">
                        Octubre
                      </font>
                    </td>
                    
                    <td align="center" bgcolor="">
                      <font size="3">
                        Noviembre
                      </font>

                    </td>
                    
                    <td align="center" bgcolor="">
                      <font size="3">
                        Diciembre
                      </font>
                    </td>




                   <input type="hidden" name="pasa1" value="0">

                   <input type="hidden" name="inicio" value="0">

</form>


<script>

                var frmvalidator = new Validator("frmadprespro");
           		frmvalidator.setAddnlValidationFunction("GRABA");




 function CONSULTA(form)
			  {

              //alert("hoLA");
              frm.inicio.value = 1;
              this.document.forms[form].submit();

			  }

</script>
 </body>
</html> 
  #5 (permalink)  
Antiguo 20/11/2006, 17:21
 
Fecha de Ingreso: agosto-2006
Mensajes: 110
Antigüedad: 17 años, 8 meses
Puntos: 1
Cita:
Iniciado por dontripi Ver Mensaje
Código HTML:
 function CONSULTA(form)
			  {

              //alert("hoLA");
              frm.inicio.value = 1;
              this.document.forms[form].submit();

			  }

</script>
 </body>
</html> 
El problema está en que recibes un parámetro form de la función CONSULTA y en la siguiente línea le llamas frm. Por otro lado yo no utilizaría 'form' porque es el nombre de un elemento 'genérico' pondría frm:

Código HTML:
 function CONSULTA(frm)
			  {

              //alert("hoLA");
              frm.inicio.value = 1;
              this.document.forms[frm].submit();

			  }

</script>
 </body>
</html> 
  #6 (permalink)  
Antiguo 20/11/2006, 21:13
Avatar de dontripi  
Fecha de Ingreso: enero-2006
Mensajes: 240
Antigüedad: 18 años, 3 meses
Puntos: 1
nada no me sale nada me sigue saliendo el error,
  #7 (permalink)  
Antiguo 21/11/2006, 04:06
 
Fecha de Ingreso: agosto-2006
Mensajes: 110
Antigüedad: 17 años, 8 meses
Puntos: 1
Hola,

En esta línea:
Código:
frm.inicio.value = 1;
frm es un String, no un formulario.
Un formulario sería document.forms[frm] como haces luego.
Si en el método consulta accedieras a campos 'inicio' de diferentes forms, estaría bien que pasases el nombre del form en la llamada consulta('esteform'), pero si sólo lo usas para ese form valdría así

Código:
function consulta() {
      document.forms["frmadprespro"].inicio.value = 1;
      document.forms["frmadprespro"].submit();
}
Y la llamada sería así:

Código HTML:
<select name="slsucursal" style="width:250" onblur="consulta()">      
      <option></option>
      <option>Armenia</option>
</select> 
Por cierto, " slsucursal" empieza por un espacio, debes quitárselo.
  #8 (permalink)  
Antiguo 21/11/2006, 06:21
Avatar de dontripi  
Fecha de Ingreso: enero-2006
Mensajes: 240
Antigüedad: 18 años, 3 meses
Puntos: 1
muchas gracias VENGAVA, me ha servido mucho tu ayuda.

ahora si puedo manejar bien los submits.
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 17:49.