I have list of DropDownList of items fetching from database, all have values of 1,2 and 3...
DropDownList1 has a selected value of 1
DropDownList2 has a selected value of 3
DropDownList3 has a selected value of 2
What I want is to swap values. It's urgent please help.
i.e. if I selected number 2 in DropDownList1, DropDownList3 should select 1 automatically.
Using Ruby on Rails to fetch the data from db, Ajax,Javascript & HTML. I tried this code from this website http://www.webdeveloper.com/forum/showthread.php?231117-Swap-values-of-DropDownList , no luck.I am looking for this exact functionality. Please help if i can get solution in js & ajax.
Below is the ruby code for fetching the details.
Expand|Select|Wrap|Line Numbers
- <select id="order_of_display" name="order[display]" >
- <% @orderNumber= item.position %>
- <%for i in (1..@items[:active].size) %>
- <%if( i == @orderNumber) %>
- <option value="<%= item.id %> " selected="selected"><%= i%></option>
- <%else%>
- <option value="<%= item.id %>"><%= i%></option>
- <%end%>
- <%end%>
- </select>