Find position of option in select

Find position of option in select

I've a bit of code taking two lists of related data. A code and a name for an organisation.

The code and name need to be in different dropdown lists (as directed from management).

I'm populating the select options from an arraylist (in a jsp).

Is there a way to find out out what position in the list of options a value is, in order to change the select in the other dropdown list. So if the third in the list of options for code was selected, the third in the list of name would change to the third option in that list.

IE if these where my drops downs.

select>code
                 >007
                 >wd40
                 >xxx
                 >006

select>name
                 > James Bond
                 > Leslie Nielsen
                 > Barbara Bach
                 > Sean Bean

So if I selected xxx in code, name would automatically adjust to Barbara Bach (and vice versa)

Thanks
Lee