duangua5742 2012-11-20 15:42
浏览 44
已采纳

将PHP变量传递给jQuery整数

basically I know more or less how to do it but would like to know if there is any better way?

I have the following variables in PHP

$day; $month; $year;

The ones above have values from exploding a php date string.

Below is PHP plugin function which states the date for countdown.

<script type="text/javascript">
$(function () {
    var austDay = new Date();   
    austDay = new Date(2013, 12, 22);
    $('#defaultCountdown').countdown({until: austDay});
});
</script>

I would like to pass the date day/month/year variables into that function from PHP how can I do it, when I tried to attach to the javavariable and put that variable in place of the date part, it didnt work.

Thanks for all help

  • 写回答

3条回答 默认 最新

  • dsf55s1233 2012-11-20 15:44
    关注
    var day  = <?php echo $day ?>; 
    var month = <?php echo $month ?>; 
    var year = <?php echo $year ?>;
    
    $(function () {
        var austDay = new Date();   
        austDay = new Date( year, month, day );
        $('#defaultCountdown').countdown({until: austDay});
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料