代码之家  ›  专栏  ›  技术社区  ›  ArK Sheeba Nancy

drupal Select cck onchange处理程序

  •  1
  • ArK Sheeba Nancy  · 技术社区  · 14 年前

    function bday_form_event_node_form_alter(&$form, &$form_state) { 
      $form['title']['#attributes'] = array('onchange' => "titleval()");
      $form['#after_build'][] = 'bday_form_event_node_form_cck_alter';
    }
    function bday_form_event_node_form_cck_alter($form, &$form_state) {
      $form['field_date1'][0]['value']['#attributes'] = array('onchange' => "dateval()"); //Text Field
     $form['field_city']['#attributes'] = array('onchange' => "cityval()"); //Select Field
    }
    

    但对于 选择

    1 回复  |  直到 14 年前
        1
  •  2
  •   Jeremy French    14 年前

    在googletorp说的基础上做一点改进。

    这不是向drupal中的表单添加行为的方法。

    JS api 这是drupal提供的帮助。

    大致上你想要的是这样的东西。

    Drupal.behaviors.myModuleBehavior = function(context) {
      $('.title').change(function() {titleval() }) ;
      $('.field_date1').change(function() {dateval()});
      $('.field_city').change(function() {cityval()});
    }