Передаем значения в скрытые поля Webform (Javascript)

Создаем файл
mytheme.js


Подключаем файл к теме

  1. function mytheme_preprocess_page(&$vars, $hook) {
  2. if (true) {
  3. drupal_add_js(drupal_get_path('theme', 'mytheme') . '/mytheme.js');
  4. $vars['scripts'] = drupal_get_js();
  5. }

Внутри файла описываем логику заполнения данных.

  1. (function ($) {
  2. Drupal.behaviors.CUSTOMNAME = {
  3. attach: function(context) {
  4.  
  5. $('input[name=INPUT_NAME]').val('NEW_VALUE');
  6.  
  7. }
  8. }
  9. })(jQuery);
Russian
Категория: 
The code has been tested and works

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Target Image