如何在Drupal的下拉列表中添加onchange处理程序?

Pra*_*V P 2 drupal drupal-6 drupal-modules

如何在Drupal的下拉列表中添加onchange处理程序?使用hook_form()添加下拉列表.我必须根据onchange功能执行一个功能.有没有办法做到这一点?

小智 7

您可以添加如下表单:

 hook_form()
 {
   $form1["dropdown"] = array(
    '#type' => 'select',
    '#title' => t('Preview the page with themes available'),
    '#options' => $ptions,
    '#default_value' => 'defalut_value',
    '#attributes' => array('onchange' => "form.submit('dropdown')"),
 );
//Submit button:
$form1['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit '),
        '#attributes' => array('style' => 'display: none;'),
);
Run Code Online (Sandbox Code Playgroud)

现在,您可以使用hook_submit()添加提交功能.