Getting the value of a select option I would like to validate the company name chosen in a form in a "select" form field.

When I try $form_values['submitted_tree']['company_1']; it shows me the key instead of the string value.

I tried the following code, but it still prints '1' (the key) instead of the value associated with the key.

    $_page_num = $form_state['values']['details']['page_num'];
    $key1 = $form_state['values']['submitted_tree']['company_1'];
    $value1 = $form['submitted_tree']['company_1']['#options'][$key1];
    $key2 = $form_state['values']['submitted_tree']['company_2'];
    $value2 = $form['submitted_tree']['company_2']['#options'][$key2];

    if (($_page_num == 2) &amp;&amp; ($value1 == $value2)) {
      drupal_set_message(print_r($form['submitted_tree']['company_2']['#options'][$key2]));
    }


Could anyone help me to retrieve the actual text value displayed in select option chosen? I have tried $form_state as well, but it returns the same result.
You can use the key to get the value by referencing the options array in the original form element:

$key = $form_state['values']['submitted_tree']['company_1'];
$value = $form['submitted_tree']['company_1']['#options'][$key];