You are here

在Drupal中轻松实现省市县3级联动菜单(付费视频PPT)

g089h515r806 的头像
Submitted by g089h515r806 on 星期五, 2009-11-06 11:04

 

AHAH helper模块

  下载地址:http://drupal.org/project/ahah_helper
•功能强大,不需要编写回调函数,不需要编写JS代码。
•注意事项:
•实质上是一个多步表单
•遵守AHAH helper模块给出的编写规范

3级联动的实例代码:

$province_sql = "SELECT * FROM {province} ";
 $province_result = db_query(db_rewrite_sql($province_sql));
 while($data = db_fetch_object( $province_result)){
  $province_options["$data->provinceID"] =$data->province ;
 }

 
 $form['profile']['province'] = array(
  '#type' => 'select',
  '#title' => t('来自省'),
  '#options' => $province_options,
  '#default_value' =>  $province_default_value,
  '#ahah' => array(
      'event'   => 'change',
      // This is the "magical path". Note that the parameter is an array of
      // the parents of the form item of the wrapper div!
      'path'    => ahah_helper_path(array('profile')),
      'wrapper' => 'profile-info-wrapper',
    ),
 );

 

 

 

论坛: