Get selected value and submit a form I have a form, and I want to get the selected value of $form['dropdown_third'] and then use the value to create my table.

What should I write in Submit function?



function find_tryk_filter_test_page($form, &amp;$form_state) {

$options_first = find_tryk_filter_test_first_dropdown_options();
$value_dropdown_first = isset($form_state['values']['dropdown_first']) ? $form_state['values']['dropdown_first'] : key($options_first);

$form['dropdown_first'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; 'Type',
    '#options' =&gt; $options_first,
    '#default_value' =&gt; $value_dropdown_first,
    '#ajax' =&gt; array(
        'event' =&gt; 'change',
        'callback' =&gt; 'find_tryk_filter_test_ajax_callback',
        'wrapper' =&gt; 'dropdown_second_replace',
    ),
);

$form['dropdown_second'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; 'Producent',        
    '#prefix' =&gt; '&lt;div id="dropdown_second_replace"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
    '#options' =&gt; find_tryk_filter_test_second_dropdown_options($value_dropdown_first),
    '#default_value' =&gt; isset($form_state['values']['dropdown_second']) ? $form_state['values']['dropdown_second'] : '',
    '#ajax' =&gt; array(
        'event' =&gt; 'change',
        'callback' =&gt; 'find_tryk_filter_test_2_ajax_callback',
        'wrapper' =&gt; 'dropdown_third_replace',
    ),
);

if (!empty($value_dropdown_second)){
    $options_second = find_tryk_filter_test_second_dropdown_options($value_dropdown_second);    
    $value_dropdown_second = isset($form_state['values']['dropdown_second']) ? $form_state['values']['dropdown_second'] : key($options_second);
}else{              
    $options_second = array();  
    $value_dropdown_second = isset($form_state['values']['dropdown_second']) ? $form_state['values']['dropdown_second'] : key($options_second);
}

//echo $options_second;
$form['dropdown_third'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; 'Model',       
    '#prefix' =&gt; '&lt;div id="dropdown_third_replace"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',        
    '#options' =&gt; find_tryk_filter_test_third_dropdown_options($value_dropdown_second),
    '#default_value' =&gt; isset($form_state['values']['dropdown_third']) ? $form_state['values']['dropdown_third'] : '',
);  


$form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Find trykluft element'),  
    '#ajax' =&gt; array(
        'callback' =&gt; 'find_tryk_filter_test_ajax_result_callback',
        'wrapper' =&gt; 'result-wrapper',
        'method' =&gt; 'replace',
        'effect' =&gt; 'fade',
        '#prefix' =&gt; '&lt;div id="replace_hotelbook_div"&gt;',
        '#suffix' =&gt; '&lt;/div&gt;'
    ),
);

$header = array('Navn', 'Shoplink', 'Brochure');

$options_third = find_tryk_filter_test_third_dropdown_options($value_dropdown_second);  
$value_dropdown_third = isset($form_state['values']['dropdown_third']) ? $form_state['values']['dropdown_third'] : key(0);
$query = db_query("SELECT node.title, fdfs.field_shoplink_value, fm.uri
    FROM node 
    JOIN field_data_field_model AS fdfm ON
    fdfm.entity_id = node.nid
    JOIN field_data_field_producent AS fdfp ON
    fdfm.entity_id = fdfp.entity_id
    JOIN field_data_field_shoplink AS fdfs
    ON fdfs.entity_id = fdfm.entity_id
    JOIN field_data_field_brochure AS fdfb
    ON fdfb.entity_id = fdfm.entity_id
    JOIN file_managed AS fm ON
    fm.fid = fdfb.field_brochure_fid
    JOIN taxonomy_term_data AS ttd
    ON fdfp.field_producent_tid = ttd.tid
    WHERE fdfm.field_model_value = '".$value_dropdown_third."'");                   

$rows = array();

foreach ($query as $row) {
    $rows[] = array($row-&gt;title, $row-&gt;field_shoplink_value, $row-&gt;uri);                        
}   

$form['webform_results'] = array(
  '#theme' =&gt; 'table',
  '#rows' =&gt; $rows,
  '#header' =&gt; $header
);

return $form;

}
What should I write in Submit function?


That's up to you, depends what you want to do. It sounds like you're just unsure how to get access to the submitted values. Those reside in $form_state['values'], so:

$value = $form_state['values']['dropdown_third'];