如何在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(