Dropdown List

Hi,

When I am selecting a particular value from DropDown(values are being populated from DB), is it possible to show the same value in dropdown.

Currently,when i am selecting any value from the dropdown the selected value is no longer visible in the dropdown list.

Need a help as i have to complete this task asap.

Many Thanks, Milley

Sorry, I have no idea what you mean. Please show us the section of code you are using to display the dropdown and explain in more detail what is going wrong.

Colin

Hi Colin,

The query which i am using on my form is :

= f.select(:word_ids, Word.order(:text).collect {|w| [ w.text, w.id ] }, { label: "Words" }, { multiple: true })

I am able to select a value from dropdown list of values.If i want to select the same value again then i can't see that value in the dropdown list anymore.

Is there any way that i can see the value in dropdown list irrespective of how many times i have selected the value.

Also,please find attached screenshot.

Thanks, Milley

Colin Law wrote in post #1178473:

Hi Colin,

The query which i am using on my form is :

= f.select(:word_ids, Word.order(:text).collect {|w| [ w.text, w.id ] }, { label: "Words" }, { multiple: true })

I am able to select a value from dropdown list of values.If i want to select the same value again then i can't see that value in the dropdown list anymore.

Is there any way that i can see the value in dropdown list irrespective of how many times i have selected the value.

Also,please find attached screenshot.

I believe that the word is still there in the list, but it is styled so that the background and text are the same colour so you cannot see the text. Normally the currently selected item would be highlighted. I guess you have specified something in a stylesheet that has caused this. In Firefox you can use Tools > Web Developer > inspector to examine the styles.

Colin

Hi Colin,

Thanks for the reply. By inspecting the element I am able to see the value in dropdown however I am not able to select that value.It's always selecting the next value when i am clicking on that value.

Also, I am not able to see the blue color background on the value which was previously being selected that basically allows me to select value.

Thanks, Milley

Colin Law wrote in post #1178481:

Hi Colin,

Thanks for the reply. By inspecting the element I am able to see the value in dropdown however I am not able to select that value.It's always selecting the next value when i am clicking on that value.

Also, I am not able to see the blue color background on the value which was previously being selected that basically allows me to select value.

In the screenshot the current selected item shows like a button with a cross by it. Where is that coming from? Is there some javascript doing it?

Colin

Hi Colin,

Its happening through javascript.

Colin Law wrote in post #1178483:

Hi Colin,

Its happening through javascript.

In that case I think it highly likely that the javascript is causing the other problem. What happens if you disable javascript in the browser?

Colin

Hi Colin,

We are using select2.js jquery plugin.

Thanks, Milley

Milley Duke wrote in post #1178484:

Hi Colin,

By disabling javascript, the drop down is not working properly.

Thanks, Ekta

Colin Law wrote in post #1178488:

Hi Colin,

By disabling javascript, the drop down is not working properly.

What do you mean, not working properly?

By the way, it would help me if you could insert your replies inline rather than top posting as it makes it easier to follow the thread. This is a mailing list not a forum, though you may be accessing it via a forum-like interface. Thanks.

Colin

Colin Law wrote in post #1178491:

A select box does not need javascript to operate. What do you see and what happens when you click it? View the source in the browser and copy/paste here the html code that you see for the select tag.

Colin

Colin Law wrote in post #1178493:

This is a mailing list not a forum, though you may be accessing it via a forum-like interface. Thanks.

Colin

Hi Colin,

Sorry for the replying that way.Will keep this in mind in Future.

Yeah, its not working like dropdown when i am disabling javascript.

A select box does not need javascript to operate. What do you see and what happens when you click it? View the source in the browser and copy/paste here the html code that you see for the select tag.

Colin

Hi Colin,

Thanks a lot for your help.

I am able to fix that issue.Just commented some code in javascript file and now its working fine.

I had a word my Lead and he is saying we have to include that file in our application as its used for other data as well.

Regards, Milley