1
我通過以下方式將onchange處理程序添加到所有cck字段。drupal選擇cck onchange處理程序
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
}
但onChange處理爲選擇沒有添加到DOM。
爲什麼在html中加入這個,而不是使用.js文件/ jQuery代替? – googletorp 2010-11-10 08:42:30