Set conditonal default value of a field
Here is how you can do it:

  $params = drupal_get_query_parameters();
  $form['cat'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; t('Categories'),
    '#options' =&gt; $categories,
  );

  if(isset($params['cat'])) {
    $form['cat']['#default_value'] = $params['cat'];
  }