我试图设计一个基本的Javascript电子邮件注册事件更新,就像您在建设中和即将推出的页面上看到的那样。访问者将添加他们的电子邮件,然后单击提交将他们自己添加到电子邮件列表中,使用基本的Ajax或jQuery“感谢您注册”消息。另外,我需要使用PHO电子邮件验证器。Javascript/PHP事件更新注册按钮
HTML
<form action="scripts/mail.php" method="POST">
<input type="email" name="email" id="email" placeholder="Enter your email here....." tabindex="1">
<input type="submit" name="submit" id="submitbtn" value="Signup" class="submit-btn" tabindex="2">
</form>
与下面的PHP文件:
<?php
$from = "[email protected]";
$email = $_POST['email'];
$to = "[email protected]";
$subject = "Please add me to the events mailing list";
$mailheader = "Email: $email \r\n";
mail($to, $subject, $mailheader) or die("Error!");
echo "<script type=\"text/javascript\">".
"alert('Thanks! We will keep you updated');".
"</script>";
?>
然后我用此Javascript SignUp.js:
$(document).ready(function(){
var mousedownHappened = false;
$("#submitbtn").mousedown(function() {
mousedownHappened = true;
});
$("#email").focus(function(){
$(this).animate({
opacity: 1.0,
width: '250px'
}, 300, function(){
// callback method empty
});
// display submit button
$("#submitbtn").fadeIn(300);
});
$("#submitbtn").on("click", function(e){
e.stopImmediatePropagation();
$("#signup").fadeOut(230, function(){
// callback method to display new text
// setup other codes here to store the e-mail address
$(this).after('<p id="success">Thanks! We will keep you updated.</p>');
});
});
$("#email").blur(function(){
if(mousedownHappened) {
// reset mousedown and cancel fading effect
mousedownHappened = false;
} else {
$("#email").animate({
opacity: 0.75,
width: '250px'
}, 500, function(){
// callback method empty
});
// hide submit button
$("#submitbtn").fadeOut(400);
}
});
});
但我需要帮助,使其正常运行。首先,我希望电子邮件说明来自哪里,但目前没有人说。
另外我知道JS和PHP似乎在电子邮件确认文本中相互覆盖。那么你能告诉我最好用什么?而他们注册后,我希望访问者留在同一页面上。谢谢。
你的代码很不明确。你的php代码和Js代码在哪里,我的意思是哪些文件 –
对不起,将您的网站从http://designwoop.com/2013/01/dynamic-newsletter-signup-form-with-jquery-动画/ –
如果您可以查看使用的代码,并帮助我正确编辑代码并帮助我了解需要添加的代码以修复代码并使其通过访问者电子邮件地址发送到特定地址 –