0

Hello All,
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

2
Contributors
6
Replies
24
Views
4 Years
Discussion Span
Last Post by shrutib
0

I have list of DropDownList of items fetching from database, all have values of 1,2 and 3...

Do you have a query? Can post what your query looks like.

0

Thank you for your reply. As of now i am able to display the drop down list fetching the details from database which is selected. I am unable to find the swapping logic. 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.

<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>
0

How can i get the current selected text value and changed text value in one javascript function? Please help.

0

How can i get the current selected text value and changed text value in one javascript function? Please help.

You can used this (it's in jQuery):

http://gotochriswest.com/blog/2011/07/22/javascript-swap/

The link you provide is 3 years old.

The code is a bit hard to modify to fit your ruby code.

You need to find something similiar and more easily to modify.

I think the jQuery code might be more easier to modify than the code from your link.

Edited by LastMitch: grammer

0

How can i get the current selected text value and changed text value in one javascript function? Please help.

0

Thank you so much. But i dont know how to use Jquery in Javascript. If possible can i get the link of working sample with the same logic with full code so that it will be easy for me to modify. Otherwise is there any way to get the already selected text value and changed text value of drop down list in one javascript function?
Thanks in advance.

Edited by shrutib: text was missing,space missing

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.