我有一个输入按钮,可以提交来自前端的内容供后端审查。问题是它没有显示确认消息-它没有设置为表单,否则这将很容易(我也不能将其更改为表单)。
输入按钮有一个唯一的ID -我想添加一个小延迟,比方说5秒,当按钮被点击时,它会显示一条消息说“谢谢,内容已提交审查”。使用Javascript或PHP可以做到这一点吗?
我有的按钮代码是:
<input type="button" class="button-primary" id="wdqs-post" value="Post">发布于 2013-06-20 17:04:12
这是你想要的吗?Test
示例Test1:
HTML Test1
<input type="button" value="Test" onclick="showAlert();"></input>JAVASCRIPT Test1
function showAlert() {
setTimeout(function() {
alert('thanks the content has been submitted for review');
},5000); // 5 seconds
}使用javascript处理onclick并在延迟前显示警报的示例:Test2
JAVASCRIPT Test2
document.getElementById("myButton").onclick=function(){showAlert()};
function showAlert() {
alert('thanks the content has been submitted for review');
setTimeout(function() {
// DO OTHER STUFF
},5000); // 5 secon
}在DIV中显示警报的示例:Test3
HTML Test3
<input id="myButton" type="button" value="Test"></input>
<div id="alert" style="display: none;">
thanks the content has been submitted for review.
</div>JAVASCRIPT Test3
document.getElementById("myButton").onclick=function(){showAlert()};
function showAlert() {
document.getElementById("alert").style.display = "block";
setTimeout(function() {
// DO OTHER STUFF
},5000); // 5 secon
}CSS Test3 (非常简单):
#alert {
border: 1px solid;
height: 20px;
width: 400px;
position: absolute;
left: 150px;
top: 40px;
}发布于 2013-06-20 18:05:38
if(isset($_POST['rbutton']) == null)
{ echo "thanks";
$time = 2;
$url = "http://localhost/method/index.php";
Header("Refresh: $time; url=$url");
exit();
}你可以使用这些php代码,它会显示消息,并在2秒延迟后,重定向任何你想要的页面…(如果这是可选的,您可以检查另一件事或服务器响应)
https://stackoverflow.com/questions/17209450
复制相似问题