弹出窗口将在给定时间段内显示

时间:2016-10-18 19:38:33

标签: javascript php jquery codeigniter

我已经创建了一个弹出窗口(在windows onload上)。我想让它每个月只在18日至25日展出。我怎么能这样做?我使用的是Codeigniter。

模型:

public function getunpaidtodate() {

    $query = $this->db->query("SELECT spp.studentid, si.firstname, 
                                      si.lastname 
                                FROM `studentpaymentplan` spp
                                    JOIN studentinfo si ON spp.studentid=si.studentid 
                                GROUP BY spp.studentid");     
    return $query->result();  
}

控制器:

$data['result'] = $this->mdl_studentinfo->getunpaidtodate();

查看文件:

<div class="alert" id='alert'>
      <span class="closebtn" id="test" onclick="this.parentElement.style.display='none';">&times;</span>
      <strong><?php  echo ' '; echo $row->firstname; echo ' '; echo $row->lastname; ?>

        <table>
        <tr>
        </tr>
        <?php foreach($result  as $r): ?>
        <tr><?php echo $r->firstname; ?>
            <?php echo $r->lastname; ?>
        </tr><br>
        <?php endforeach; ?>
        </table>
       <br></strong> pay soon !
</div>

谢谢!

2 个答案:

答案 0 :(得分:0)

<script>

$(function() {

 var now = new Date();
        if (now.getDate() >= 18 && now.getDate() <= 25) {
            run_pop_up_function();
        }
});

</script>

答案 1 :(得分:0)

我更新了上面的脚本并添加了id =&#39; alert&#39;对于视野中的div

<script>
$(document).ready(function(){
     var now = new Date()
     if(now.getDate() <= 19 ){
    $(window).load(function(){
        // alert("Page loaded.");
         $('#alert').hide();
    });
 }
});
</script>