我有一个基于该状态表中所选项目的状态下拉列表(drupal 7 中的列表),我也有复选框。当我从下拉列表中选择任何州时,所选州下的城市希望显示为复选框。我的代码是
function signup_form($form, &$form_state) {
 $form['rate_the_service']['state'] = array(
    '#type' => 'select',
    //'#title' => 'State/Province',
    '#prefix'=>'<div id="dropdown-third-replace">',
    '#suffix'=>'</div>',
    '#options'=>$opt,
    '#attributes'=>array('selected'=>array('selected')),
 '#validated' => TRUE,
  '#ajax' => array(
      'callback' => 'ajax_example_dependent_dcheck_state_callback',
      'wrapper' => 'dropdown-four-replace',
    ),
  );
   $form['rate_the_service']['city'] = array(
    '#prefix'=>'<div id="dropdown-four-replace">',
    '#type' => 'checkboxes',
    '#options' => '',
    '#default_value' => isset($values['states']) ? $values['states'] : NULL,
    '#suffix'=>'</div></div>',
  );
}
阿贾克斯调用
function ajax_example_dependent_dcheck_state_callback($form, $form_state) {
   $state = $form_state['values']['state'];
       $state_query_result2 = db_query('SELECT cityname FROM cities WHERE varstatekey = :varstatekey', array(':varstatekey' => $state));
        $state_array = array();
       // $state_array[0] = '-- Select State --';
        foreach($state_query_result2 as $row2){
            $state_array[$row2->cityname] = $row2->cityname;
        }
        $options[$state] = $state_array;
    $form['rate_the_service']['city']['#options'] = $state_array;
    //print_r($form['rate_the_service']['city']['#options']);
    return $form['rate_the_service']['city'];
}
如何解决这个问题。