我想将一个js变量传递给drupal php变量并显示其值。 以下是我的代码。如何将js变量传递给drupal php变量?
$form['title'] = array(
'#type' => 'select',
'#title' => t('titles'),
'#page callback' => 'drupal_get_form',
'#page arguments' => array('test_select'),
'#access callback' => TRUE,
'#options' => $options,
'#prefix' => '<div>',
'#postfix' => '</div>',
'#attributes' => array('onchange' => 'test_change')
);
$form['titletext'] = array(
'#type' => 'textfield',
'#title' => 'title',
);
drupal_add_js('$('.$form['title']['select'].').change(function() {
var str ="";
'.$a.' = "";
$("'.$form['title']['select'].' option:selected").each(function() {
str += $(this).text() + " ";
});
})
.change();', 'inline', 'header');
我想那str变量分配给文本字段的值,还是只分配变量Drupal的PHP变量,显示在页面上。
现在我想从数据库检索日期根据下拉列表中的选择。 – Ahmad 2011-04-19 07:50:33