Jump to content

how to pass js variable to drupal php variable????


hmdnawaz

Recommended Posts

 

I want to pass a js variable to drupal php variable and display its value. Following is my code.

 

$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');

 

 

I want to assign that str variable to the textfield value or simply assign that variable to drupal php variable and display it on the page.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.