Ver Mensaje Individual
  #4 (permalink)  
Antiguo 22/03/2011, 11:28
Avatar de Perr0
Perr0
 
Fecha de Ingreso: mayo-2005
Ubicación: Santiago de Chile, Chile
Mensajes: 676
Antigüedad: 18 años, 10 meses
Puntos: 79
Respuesta: button o submit

hay veces que un ejemplo habla mas que mil palabras
create un archivo php y le pegas esto....ahi veras el comportamiento

Código PHP:
Ver original
  1. Formulario 1 (cons submit)
  2. <form name="form1" onsubmit="return enviar1()">
  3.   <input type="text" name="t1" id="t1">
  4.   <input type="submit" name="bf1_1" id="bf1_1" value="Enviar GET" onclick="o=0">
  5.   <input type="submit" name="bf1_2" id="bf1_2" value="Enviar POST" onclick="o=1">
  6. </form>
  7. <hr>
  8. Formulario 2 (cons button)
  9. <form name="form2">
  10.   <input type="text" name="t2" id="t2">
  11.   <input type="button" name="bf2_1" id="bf2_1" value="Bot&oacute;n GET" onclick="enviar2(0)">
  12.   <input type="button" name="bf2_2" id="bf2_2" value="Bot&oacute;n POST" onclick="enviar2(1)">
  13. </form>
  14.  
  15. <script>
  16. var o
  17. var formulario1=document.form1;
  18. var texto1=document.getElementById("t1");
  19.  
  20. var formulario2=document.form2;
  21. var texto2=document.getElementById("t2");
  22.  
  23. function enviar1(){
  24.     if(!texto1.value){
  25.         alert("ingrese algo en el texto 1");
  26.         return false;
  27.     }
  28.     if(o==0){
  29.         formulario1.method="get";
  30.         formulario1.action="index.php";
  31.     }else if(o==1){
  32.         formulario1.method="post";
  33.         formulario1.action="index.php";
  34.     }
  35. }
  36.  
  37. function enviar2(o){
  38.     if(!texto2.value){
  39.         alert("ingrese algo en el texto 2");
  40.         return false;
  41.     }
  42.     if(o==0){
  43.         formulario2.method="get";
  44.         formulario2.action="index.php";
  45.     }else if(o==1){
  46.         formulario2.method="post";
  47.         formulario2.action="index.php";
  48.     }
  49.     formulario2.submit();
  50. }
  51.  
  52. </script>
  53. <hr />
  54. <h1>Resultados</h1>
  55. <?
  56. echo "valor submit GET Formulario 1: ".htmlentities($_GET["t1"])."<br>";
  57. echo "valor submit POST Formulario 1: ".htmlentities($_POST["t1"])."<br>";
  58. echo "valor submit GET Formulario 2: ".htmlentities($_GET["t2"])."<br>";
  59. echo "valor submit POST Formulario 2: ".htmlentities($_POST["t2"])."<br>";
  60.  
  61. ?>

salu2
__________________
Numerador Mp3 en Access =)
http://www.mediafire.com/download/r9...pdw/mp3(2).zip