每隔10分钟显示一个提交按钮


Show a submit button during 1 minute every 10 minutes

我想创建一个事件,用户可以每10分钟发布一些内容。

因此,提交按钮必须在1分钟内允许。此外,用户可以在不允许的时间段内检查倒计时。

是可能的JavaScript/jQuery或PHP?

是的,当页面加载时,你可以在html标记中默认禁用提交按钮。

,然后使用倒计时定时器,这是一个jquery,我以前用过http://keith-wood.name/countdown.html

在提供的代码示例链接中单击callbacks选项卡,在回调/触发函数中添加以下javascript或类似的内容。

$('#submitButtonId').attr('disabled', 'false);

试试这个:

在你的php post方法中设置下一次会话var:

<?php
   //intser post code
   $_SESSION['next_post'] = time() + (10 * 60);

然后在你的模板中打印js:

<script>
var nextPostTime = <?=$_SESSION['next_post']?>;
setInterval(function(){
    if((new Date()).getTime() > nextPostTime ){
       $('#newpostID').show(); // this is the element id of the form 
       setTimeout(function(){
            $('#newpostID').hide();
            nextPostTime = (new Date()).setMinutes((new Date()).getMinutes + 1)
        }
       ,60000);
    }
}, 1000);