JavaScript - document.forms].submit();

 
Vista:

document.forms].submit();

Publicado por Adriana (1 intervención) el 24/09/2013 02:32:52
Hola a todos, muchas gracias por su atención a mi problema:
Las consultas no son recibidas cuando se realizan por Chrome, si por el resto de los navegadores, alguien puede ayudarme.
Copio el codigo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<!-- tiene que estar porque no anda el boton enviar de contacto !! -->
<script type="text/javascript" src="../js/mootools.js"></script>
</head>
<body>
*
*
*
 
					<form method="POST" action="enviar_mail_ant.php" name="form_consulta" id="form_consulta">
 
				    <input type="hidden" name="enviado" value="enviado" id="enviado">
 
					   <TABLE WIDTH = 450px align="center">
							<tr>
							    <td align="right"><b>(*)Nombre:</b></td>
								<td> <input type="text" name="nombre_consulta" id="nombre_consulta"  size="30" maxlength="50" value=""> </td>
 
							</tr>
							<tr>
								<td align="right"><b>(*)Apellido:</b></td>
							    <TD> <INPUT TYPE="text" name="apellido_consulta" id="apellido_consulta" size="30" maxlength="50" value=""> </td>
 
						    </tr>
						    <tr>
								<td align="right"><b>(*)Ciudad:</b></td>
							    <TD> <INPUT TYPE="text" name="direccion_consulta" id="direccion_consulta" size="30" maxlength="50" value=""> </td>
						    </tr>
						    <tr>
								<td align="right"><b>Tel&eacute;fono:</b></td>
							    <TD><INPUT TYPE="text" name="telefono_consulta" id= "telefono_consulta" size="30" value=""> </td>
 
						    </tr>
							<tr>
								<td align="right"><b>(*)Email:</b></td>
								<td> <input type="text" name="email_consulta" id="email" size="30" maxlength="50" value="">
								</td>
							</tr>
							<tr>
								<td align="right"><b>(*)Como nos conoci&oacute;?:</b></td>
								<td> <select name="nos_conoce_consulta" id="nos_conoce_consulta">
								      <option value="" SELECTED>Seleccione</option>
									  <option value="Por un amigo">Por un amigo</option>
									  <option value="Por Internet">Por Internet</option>
									  <option value="Por mi trabajo">Por mi trabajo</option>
									  <option value="Por otros">Por otros</option>
									  </select>
								</td>
 
							</tr>
							<tr>
								<td align="right"><b>(*)Consulta:</b></td>
								<td> <textarea cols="40" align="left" name="comentarios_consulta" id="comentarios_consulta" rows="12"></textarea></td>
 
							</tr>
							<tr>
							    <td align="left" colspan="2" style=color:#848284;>(*) Datos Obligatorios.</td>
							</tr>
							<tr>
					    	    <td align="right" colspan="2">
					   	        <input type="button" name="btEnviar" id="btEnviar" value="Enviar">
					            <input type="reset" value="Borrar"></td>
						    </tr>
					   </table>
					   </form>
		</div>
 
</div> <!-- conten_pag -->
 
 
    <script language="Javascript" >
 
 
		function isEmailAddress(email)
		{
	 	var s = email;
		 var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
		 if (s.length == 0 ){
		    return false;}
		 if (filter.test(s)){
		    return true;}
		 else{
		    return false;}
		}
 
		function validar_contacto()
		{
 
			texto = '';
 
			if (document.getElementById('nombre_consulta').value == "")
	    	{
			  texto = texto + "Llene Nombre";
	          document.getElementById('nombre_consulta').focus();
	        }
 
	        if (document.getElementById('apellido_consulta').value == "")
	    	{
			  texto = texto + "\nLlene Apellido";
	          document.getElementById('apellido_consulta').focus();
 
	        }
 
	        if (isEmailAddress($('email').value) == false)
	    	{
			  texto = texto + "\nIngrese una direccion de correo valida"
	          document.getElementById('email').focus();
 
	        }
 
	        if (document.getElementById('nos_conoce_consulta').value == "")
	    	{
			  texto = texto + "\nLlene como nos conoce";
	          document.getElementById('nos_conoce_consulta').focus();
	        }
 
	        if (document.getElementById('comentarios_consulta').value == '')
			{
	            texto = texto + "\nLLene Comentarios";
				document.getElementById('comentarios_consulta').focus();
			}
 
	    	if (texto != '')
		    {
				alert(texto);
				return false;
			}
			else
			{
 
			$('form_consulta').submit();
			   alert("Gracias por su Consulta, la contestaremos a la brevedad.");
			   location.href="../index.html";
			}
		}
 
		$('btEnviar').addEvent('click',function(){
 
			validar_contacto();
 
		});
 
	</script>
</body>
</html>

enviar_mail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
ini_set(sendmail_from,'info@web.com');
 
if ($_POST["enviado"] == "enviado")
 
{
 
 
//Estoy recibiendo el formulario, compongo el cuerpo 
    $cuerpo = "Formulario enviado desde la Pagina web\n";
    $cuerpo .= "Nombre: " . $_POST["nombre_consulta"] . "\n";
    $cuerpo .= "Apellido: " . $_POST["apellido_consulta"] . "\n";
    $cuerpo .= "Direccion: " . $_POST["direccion_consulta"] . "\n";
    $cuerpo .= "Teléfono: " . $_POST["telefono_consulta"] . "\n";
    $cuerpo .= "Email: " . $_POST["email_consulta"] . "\n";
    $cuerpo .= "Nos conoce por: " . $_POST["nos_conoce_consulta"] . "\n";
    $cuerpo .= "Comentarios: " . $_POST["comentarios_consulta"] . "\n";
 
    //mando el correo... 
    mail("info@web.com","Consulta Souvenirs desde Web ",$cuerpo);
}
?>

ACLARO QUE [email protected] seria cualquier direccion de mail.

ESPERO SU AYUDA!
MUCHISIMAS GRACIAS
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.162
Oro
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

document.forms].submit();

Publicado por xve (2100 intervenciones) el 24/09/2013 07:48:30
Hola Adriana, he revisado tu código, y creo que tienes algo mal... una vez muestras el alert(...), no deberías redireccionar la pagina a index.html, porque entonces, no llega a la pagina php...

Quita esta linea:
location.href="../index.html";

Porque tienes puesta esta linea?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar