0

我有一个输入按钮,可以从前端提交内容以供后端审核。问题是它没有显示确认消息 - 它没有设置为表单,否则这很容易(我也无法将其更改为表单)。

输入按钮有一个唯一的 ID - 我想在单击按钮时添加一个 5 秒的小延迟,并显示一条消息“感谢内容已提交审核”。这可以用 Javascript 或 PHP 实现吗?

我的按钮代码是:

<input type="button" class="button-primary" id="wdqs-post" value="Post">
4

2 回答 2

0

这是你想要的吗?测试

示例测试1:

HTML 测试 1

<input type="button" value="Test" onclick="showAlert();"></input>

JAVASCRIPT 测试1

function showAlert() {
    setTimeout(function() {
        alert('thanks the content has been submitted for review');
    },5000);   // 5 seconds
}

使用 javascript 处理 onclick 并在延迟前显示警报的示例:Test2

JAVASCRIPT 测试2

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 测试 3

<input id="myButton" type="button" value="Test"></input>

<div id="alert" style="display: none;">
    thanks the content has been submitted for review.
</div>

JAVASCRIPT 测试3

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-20T09:04:12.160 回答
0
if(isset($_POST['rbutton']) == null)
{   echo "thanks";
    $time = 2; 
    $url = "http://localhost/method/index.php";  
    Header("Refresh: $time; url=$url");  
    exit();
}

您可以使用这些 php 代码,它显示消息并在 2 秒延迟后重定向您想要的任何页面...(如果是可选的,您可以检查其他内容或服务器响应)

于 2013-06-20T10:05:37.800 回答