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

图片转代码服务由CSDN问答提供 功能建议

基本上我或多或少知道怎么做但想知道是否有更好的方法?

我在PHP中有以下变量

  $ day;  $月;  $ year; 
   
 
 

上面的内容中有来自php日期字符串的值。

下面是PHP插件函数,其中说明 倒计时的日期。

 &lt; script type =“text / javascript”&gt; 
 $(function(){
 var austDay = new Date(); \  n austDay = new Date(2013,12,22); 
 $('#defaultCountdown')。countdown({until:austDay}); 
}); 
&lt; / script&gt; 
  <  / pre> 
 
 

我想将日期/月/年变量从PHP传递到该函数 我可以这样做,当我尝试附加到javavariable并将该变量放在 日期部分,它没有用。

感谢所有帮助

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

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条)

相关推荐 更多相似问题