Vous êtes sur la page 1sur 3

FORMULARIO CON CAPAS

Lee atentamente las indicaciones, desarrllalo y enva tu archivo a


travs de este medio:
Desarrollar un formulario donde se ingrese un cdigo de artculo y
al hacer click en un botn se elimine. En un documento de Word
poner el cdigo de lo siguiente:
Procedimientos
Almacenados,
CapaDatos,
CapaNegocio,
CapaEntidad, JSP. Finalmente comprima sus archivos en un Winrar
y envelo.
Solucin:
<script>
jQuery(function() {
jQuery('#loading').hide();
jQuery('#result').hide();
jQuery('#loading').ajaxStart(function() {
$('#forma').slideUp('slow');
$('#result').show('slow');
$(this).show();
}).ajaxStop(function() {
$(this).hide();
// $('#result').fadeIn('slow');
}).ajaxError(function(a, b, e) {
throw e;
});
jQuery.fn.reset = function () {
$(this).each (function() { this.reset(); });
};
submitHandler: function(form) {
jQuery(form).ajaxSubmit({
target: "#result"
});
$('#formSubscripcion').reset();
}
});
</script>
El html:
<div id="boletin">
<div id="result"><div id="loading"></div></div>
<div id="forma">
<form action="ajax/envio.php" method="post" name="formSubscripcion"
id="formSubscripcion">
<h3>Quiere mantenerse al da de nuestras noticias?<br />

Suscrbase al boletn de noticias de Javier</h3>


<table>
<tr>
<td class="sobre" rowspan="2"><img src="images/newsletter_sobre.jpg"
alt="" width="256" height="197" /></td>
<td style="padding-left:20px;vertical-align:middle;"><input name="nombre"
type="text" value="Nombre" onfocus="if (this.value=='Nombre')
this.value='';" onblur="if (this.value=='') this.value='Nombre';" />
<br />
<input name="email" type="text" value="Email" onfocus="if
(this.value=='Email') this.value='';" onblur="if (this.value=='')
this.value='Email';" />
</td>
</tr>
<tr>
<td style="padding-left:20px;vertical-align:top;"><span id="spizq"><img
src="images/ok.png" width="32" height="32" alt="Privado" style="textalign:center;" /> Privado</span><span id="spder"><input
name="inscripcion" type="submit" value="Inscribirse" /></span></td>
</tr>
</table>
</form>
</div>
</div>

y por ltimo el script envio.php


<script type="text/javascript">
jQuery(document).ready(function(){
$("a.oculta").click(function () {
$('#result').hide('slow');
$('#forma').show();
this.reset();
});
});
</script>
<?php include("../pcontrol/clases/eazsql.class.php");
include('../pcontrol/clases/eazloc.php'); ?>
<?php
$email = $_POST['email'];
$emailQuery = "SELECT email FROM boletin WHERE email = '$email'";
$rowEmail = $sql->get_row($emailQuery);
$total = $sql->count($emailQuery);
if(!$total){
$fecha_alta = date('Y-m-d',time());

$data =
array(nombre=>$_POST['nombre'],email=>$_POST['email'],activo=>0,fecha_a
lta=>$fecha_alta);
if($sql->insert('boletin',$data)){
$mensaje = "Tus datos fueron enviados correctamente <b>".
$_POST['nombre']."</b>";
}else{
$mensaje = "Ha ocurrido un error<br />";
}
}else{
$mensaje = "Esta direccion de email ($email) ya est registrada, por favor <a
href=\"javascript:void(0);\" class=\"oculta\">escriba otra</a> o solicite el alta
de nuevo llamando al n +55 555 555 555 o por email a
loqueseaatnosedonde.com";
}
echo $mensaje;
?>

Vous aimerez peut-être aussi