用户点击“提交”后,如何获得弹出框或简单的“谢谢”?最简单的方法:
<div id="suggestion">
<div class="control-group">
<div class="controls">
<input type="submit" value="Send" class="btn btn-info" />
这是PHP:
<?php
// Email of sender
$videogamename = $_POST['namevideogame'];
// From (Sender Name)
$artistname = $_POST['nameofartist'];
$header = "from: Game AMV";
// Message
$message = "Name of Video Game: ".$videogamename."\r\n\nName of Artist/Song: ".$artistname."\r\n\nLink: ".$_POST['link'];
// Enter your email address
$to ='something@gmail.com';
$send_contact = mail($to, 'New Song Suggestion from gameamv.com', $message, $header);
// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
header("location: http://gameamv.com/");
} else {
echo "Error. The form was not submitted. Please try again.";
}
?>
答案 0 :(得分:1)
简单 - 为您的<form>
元素提供可识别的id
值。
然后您将按如下方式挂钩onsubmit
事件:
document.getElementById('myThankfulForm').addEventListener('submit', function () {
alert("Thankful Form is Thanking you!");
}, false);
这是一个演示jsFiddle。
答案 1 :(得分:0)
如果您希望在发送电子邮件后弹出(在页面重新加载后),我会在重定向到目标网页之前在会话值中添加一条消息。然后在目标网页上,检查是否设置了会话值,是否有登录页面回显一些Javascript以提醒消息,然后将会话值设置为空。
当然我假设这是一个应用程序。