如何在JavaScript代码中获取php变量? [英] How to get a php variable in a javascript code?

查看:129
本文介绍了如何在JavaScript代码中获取php变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究drupal几周,我找不到解决这个问题的方法。



我做了一个variable_set($ name,$价值)在一种形式。表单是一个复选框,用于激活或停用幻灯片。我有一个名为active的js变量,我想在其中放入variable_get($ name)的值。这是我的js代码:

Hi, I am working on drupal for few weeks and I can't find a solution for this problem.

I made a variable_set($name,$value) in a form. The form is a checkbox and is used to activate or desactivate a slideshow. I have a js variable called active and I want to put the value of variable_get($name) in it. Here is my js code:

(function($) {
  $(document).ready(function(){
      var slidePause = 7000;
      var active = 0;

      if (active == 0){
        $('#big-slider').bxSlider({
         auto: true,
         controls: false,
         autoDirection: 'prev',
         autoStart:true,
         pause: slidePause
        });
        $('#little-slider').bxSlider({
         displaySlideQty: 3,
         moveSlideQty: 1,
         auto: true,
         controls: false,
         autoStart:true,
         pause: slidePause
        });
      }
      else { 
      $('#big-slider').bxSlider({
         auto: true,
         controls: false,
         autoDirection: 'prev',
         autoStart:false,
         pause: slidePause
        });
        $('#little-slider').bxSlider({
         displaySlideQty: 3,
         moveSlideQty: 1,
         auto: true,
         controls: false,
         autoStart:false,
         pause: slidePause
        });
      }
  });
}(jQuery));

推荐答案

name,


value in in表单。表单是一个复选框,用于激活或停用幻灯片。我有一个名为active的js变量,我想在其中放入variable_get(
value) in a form. The form is a checkbox and is used to activate or desactivate a slideshow. I have a js variable called active and I want to put the value of variable_get(


name)的值。这是我的js代码:

name) in it. Here is my js code:
(function(


这篇关于如何在JavaScript代码中获取php变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆