我为这个问题的标题道歉,因为我知道它似乎有点宽泛。不幸的是,我对 jquery 还是很陌生,过去我得到了很多帮助来完成这项工作,现在我想改变一些事情,我很头疼。
我在这里有一个网站:http ://www.rattletree.com 有一个时事通讯注册表单,当用户单击电子邮件框时,名称和城市字段也会下拉以填充。这一切都很好,但现在的工作方式是,信息直接发送到我的电子邮件地址,我需要手动将这个人输入到我们的电子邮件营销程序中。我现在希望通过从程序提供的嵌入代码中获取所需信息,将此信息直接发送到我们的电子邮件营销程序。我已经为此工作了几天,有时我设法将信息发送到程序而不隐藏 div,有时我设法隐藏 div 而没有正确发送表单。我有点失落。我希望有人可以帮助我正确合并这两件事。
这是发送到我自己的电子邮件地址的当前实时网站的工作代码:
(在标题中)
<div class="outeremailcontainer">
<div id="emailcontainer">
<?php include('verify.php'); ?>
<form action="../index_success.php" method="post" id="sendEmail" class="email">
<h3 class="register2">Newsletter Signup:</h3>
<ul class="forms email">
<li class="name">
<label for="yourName">Name: </label>
<input type="text" name="yourName" class="info" id="yourName" value="<?php echo $_POST['yourName']; ?>" /><br />
</li>
<li class="city"><label for="yourCity">City: </label>
<input type="text" name="yourCity" class="info" id="yourCity" value="<?php echo $_POST['yourCity']; ?>" /><br />
</li>
<li class="email">
<label for="emailFrom">Email: </label>
<input type="text" name="emailFrom" class="info" id="emailFrom" value="<?php echo $_POST['emailFrom']; ?>" />
<?php if(isset($emailFromError)) echo '<span class="error">'.$emailFromError.'</span>';
?>
</li>
<li class="buttons email">
<button type="submit" id="submit">Send</button>
<input type="hidden" name="submitted" id="submitted" value="true" />
</li>
</ul>
</form>
<div class="clearing">
</div>
</div>
</div>
剧本:
$(document).ready(function () {
$('#emailFrom').focus(function () {
if ($('#overlay').length) {
return;
} // don't keep adding overlays if one exists
$('#sendEmail').find('.name, .city').slideDown(300, function () {
$(this).show();
});
$('.outeremailcontainer').css({
position: 'relative',
bottom: 0,
left: 0,
zIndex: 1001
});
$('<div id="overlay"></div>').appendTo('body');
});
$('#overlay').live('click', function () {
$('#sendEmail').css({
backgroundColor: 'transparent'
}).find('.name, .city').slideUp(300);
$('.outeremailcontainer').css({
position: 'static'
});
$('#overlay').remove();
});
});
在页面底部的包含中:
$(document).ready(function () {
$("#submit").click(function () {
$(".error").hide();
var hasError = false;
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var emailFromVal = $("#emailFrom").val();
if (emailFromVal == '') {
$("#emailFrom").after('<span class="error"><br />You forgot to enter the email address to send from.</span>');
hasError = true;
} else if (!emailReg.test(emailFromVal)) {
$("#emailFrom").after('<span class="error"<br />>Enter a valid email address to send from.</span>');
hasError = true;
}
var yourNameVal = $("#yourName").val();
if (yourNameVal == '') {
$("#yourName").after('<span class="error"><br />You forgot to enter your name.</span>');
hasError = true;
}
var yourCityVal = $("#yourCity").val();
if (yourCityVal == '') {
$("#yourCity").after('<span class="error"><br />You forgot to enter your city.</span>');
hasError = true;
}
if (hasError == false) {
$(this).hide();
$("#sendEmail li.buttons").append('<img src="/wp-content/themes/default/images/template/loading.gif" alt="Loading" id="loading" />');
$.post("/includes/sendemail.php",
//emailTo: emailToVal,
{
emailFrom: emailFromVal,
yourName: yourNameVal,
yourCity: yourCityVal
},
function (data) {
$("#sendEmail").slideUp("normal", function () {
$("#sendEmail").before('<h3 class="register2">Thank you! You\'re on the email list!</h3><p class="emailbox">Click <a href="http://rattletree.com/Songs/Live_EP/Chikende.mp3">HERE</a> for your free song.</p>');
});
}
);
}
return false;
});
});
最后,这是电子邮件营销程序提供的代码,我想将上述姓名、城市和电子邮件信息发送到:
<form action="https://madmimi.com/signups/subscribe/66160" method="post" id="mad_mimi_signup_form">
<fieldset>
<div class="mimi_field text email required">
<label for="signup_email">Email</label>
<input id="signup_email" name="signup[email]" type="text" placeholder="you@example.com" class="required">
<div class="mimi_field_feedback"></div><span class="mimi_funk"></span>
</div>
<div class="mimi_field text required">
<label for="signup_name" id="wf_label">Name</label>
<input id="signup_name" name="signup[name]" type="text" class="required">
<div class="mimi_field_feedback"></div><span class="mimi_funk"></span>
</div>
<div class="mimi_field text required">
<label for="signup_city" id="wf_label">City</label>
<input id="signup_city" name="signup[city]" type="text" class="required">
<div class="mimi_field_feedback"></div><span class="mimi_funk"></span>
</div>
<div class="mimi_field action">
<input id="webform_submit_button" value="Sign up!" type="submit" class="submit" data-default-text="Sign up!" data-submitting-text="Sending…" data-invalid-text="? You forgot some required fields">
</div>
</fieldset>
</form>
非常感谢您的帮助!