hmdnawaz Posted April 19, 2011 Share Posted April 19, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/234131-how-to-pass-js-variable-to-drupal-php-variable/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.