How to get select option id value in form api Hi hello please help how to get dynamically selected option id value (i.e #options=&gt;0=&gt;'bala',1=&gt;'kumar') 

for example 
how to get selected value of ID value in form api in drupal  

$form['state1']= array(
  '#type' =&gt; 'select',
  '#title' =&gt; t('State'),
  '#options' =&gt;$options_state,
  '#required' =&gt; TRUE,
  '#ajax' =&gt; array(
    'callback' =&gt; '_ajaxfunction',
    'wrapper' =&gt; 'divaroundseconddropdown'
  ),
);


the selected value store in $key value, please help me how to do....

$key = !empty($form_state['values']['state1']) ? $form_state['values']['state1'] : 1;


is this correct???
You can get the value using:

$form['field_name'][#options][$form_state['values']['field_name']]