Adding a class to select options from Views Exposed Filters Currently I have a views exposed filter for a "City" field. Typical output looks like:

&lt;option value="Liverpool"&gt;Liverpool&lt;/option&gt;


I would love to be able to add a class to this such as:

&lt;option value="Liverpool" class="north-west"&gt;Liverpool&lt;/option&gt;


I currently have a CCK field "field_region" which is set to "North West" for Liverpool - so it would be brilliant if anyone had any suggestions with how to achieve this on my exposed form input.

Cheers,
Garry.
Normally this would be accomplished with hook_form_alter, but sadly Drupal 6 doesn't support attributes in the options Form API element, which means you can't add any classes to it.

You're going to have to do this with Javascript. :-(

You can't start with something like this:

  $('.view-NAME_OF_YOUR_VIEW .views-exposed-widget option').each(function(index) {
    $(this).addClass($(this).val());
  });


This will get you

&lt;option value="Liverpool" class="Liverpool"&gt;Liverpool&lt;/option&gt;


I know it's not perfect, but sadly that's probably the simplest route.