Onchange of one select_tag, it should update another select_tag which is having same selected value

Dear all,

   I have two columns in a table: 1. vehicles, 2. drivers.
The table lists all the vehicles in vehicles column and drivers column
will have select_tag dropdown to select a driver.

For ex, following drivers are set to vehicles.

vehicle1 -> driver1
vehicle2 -> select
vehicle3 -> driver2

Here, when change driver for vehicle1 from driver1 to driver2 using
drop-down list, I am updating the database table for both vehicle1 and
vehicle3. But I need to update the driver to 'select' for vehicle3. May
I know how can I do this?

Thanks,
Ajit

What have you tried and what about it did not work?

Colin

This is the code which I am using for select_tag.

<td align='center'>
                <% driver = d.driver ? d.driver : nil %>
                <% selected = d.driver.nil? ? 0 : d.driver.id %>
<% current_drivers = @current_user.sorted_drivers.collect{ |u| [u.name,
u.id]} %>

<%= select_tag(:id, options_for_select( [["Select", 0]] +
current_drivers, selected ),
:onchange => ( "if (confirm('Would you like to assign driver ' +
this.options[this.selectedIndex].text + ' to device #{ d.s_uf_name}?'))
{" + remote_function(
:url=> { :controller => :limos, :action => :updatedrivervehicle,
:device_id => d.id, :predriver_id => d.driver}, :method => :post,
:with => with_params( :driver_id
=>'this.options[this.selectedIndex].value' )) + "; sdvs[#{ i }] =
this.selectedIndex; } else { this.selectedIndex = sdvs[#{ i }]; }")) %>
<% old_index= driver ? (current_drivers.index( [driver.name,driver.id]
))+1 : 0 %>
<%= javascript_tag "sdvs[#{ i }] = #{old_index} " %>
</td>