我已经重新表述了我的第一个问题,因为我认为它太模糊了!
的情况:santz.net/index.contacto.html(如果你想尝试发送一些东西,它是好的…我收到了,所以没问题)
下面是我的代码.....
联系人表单:
<form id="contact-form" name="contact-form" class="p25" action="contact.php" method="post">
<fieldset>
<label class="name">
<input class="input" type="text" value="Nombre" onfocus="if(this.value == 'Nombre'){this.value = '';}" onblur="if(this.value == ''){this.value='Nombre';}" name="php_name" />
</label>
<label class="email">
<input class="input" type="email" value="Email" onfocus="if(this.value == 'Email'){this.value = '';}" onblur="if(this.value == ''){this.value='Email';}" name="php_email" />
</label>
<label class="phone">
<input class="input" type="tel" value="Teléfono" onfocus="if(this.value == 'Teléfono'){this.value = '';}" onblur="if(this.value == ''){this.value='Teléfono';}" name="php_phone" />
</label>
<label class="message">
<textarea class="textarea" onfocus="if(this.value == 'Mensaje'){this.value = '';}" onblur="if(this.value == ''){this.value='Mensaje';}" name="php_message">Mensaje</textarea>
</label>
<div class="buttons-wrapper ml20">
<div class="submit-comment">
<span></span>
<input type="reset" value="Cancelar">
</div>
<div class="submit-comment ml25">
<span></span>
<input type="submit" value="Enviar">
<div id="clicker"></div>
</div>
</div>
</fieldset>
</form>
下面是我的PHP代码:
<?php
$field_name = $_POST['php_name'];
$field_email = $_POST['php_email'];
$field_phone = $_POST['php_phone'];
$field_message = $_POST['php_message'];
$field_sender = 's2@hotmail.com';
$mail_to = 's@hotmail.com';
$subject = 'Mensaje via Santz.net de '.$field_name;
$body_message = 'From: '.$field_name."'n";
$body_message .= 'E-mail: '.$field_email."'n";
$body_message .= 'Phone: '.$field_phone."'n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_sender."'r'n";
$headers .= 'Reply-To: '.$field_email."'r'n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Gracias por contactarse, en breve, me pondre en contacto.'n'nSantz Design | www.santz.net');
window.location = 'index.contacto.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('El envio fallo. Por favor, envie un mail directamente a info@santz.net');
window.location = 'index.contacto.html';
</script>
<?php
}
?>
我想做的是:
联系方式现在工作,我收到了电子邮件…这很好…所以:
1-我需要消除提交表单时的页面刷新/重定向2-取代刷新/重新加载/重定向,我需要,当表单提交时,我希望它打开一个模态窗口(我会把任何内容在那里…)(示例:pixeden.com/media-icons/soft-media-icons-set-vol-2…当我点击"下载"时打开的对话框)
这是另一个用户推荐给我的模态框(它很好):mywebdeveloperblog.com/my-jquery-plugins/modalpoplite
问题是我不明白如何在提交后删除重新加载/刷新/重定向问题,我不明白如何在提交表单后连接模态框打开事件…
注意:
我对这一切都很陌生(我只有17岁),所以我不是一个程序员…只是一个懂一点编程的设计师……但是我正在学习网络编程,所以我需要帮助。
如果PHP不是我要走的路,我需要改变编程技术,请告诉我。我对任何能完全解决我的问题的编程语言都持开放态度!
非常感谢!
将此脚本放入联系人表单的<head>
:
<link href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script type="text/javascript">
$(function() {
$("#dialog-modal").dialog({
height: 140,
modal: true,
autoOpen: false
});
$('#contact-form').submit(function() {
$("#dialog-modal").dialog("open");
$.ajax({
type: "POST",
url: $(this).attr('action'),
data: $(this).serialize(),
success: function() {
$("#dialog-modal").dialog("close");
}
});
return false;
});
});
</script>
粘贴到正文的任意位置:
<div id="dialog-modal">Form submitted</div>
Santz,他们最有可能使用ajax和jquery UI对话框来显示当javascripts ajax响应返回时。这里有一个很好的小教程,解释他们是如何做到这一点的。好运。
http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/