Skip to content Skip to sidebar Skip to footer

Select Already Selected Item In Dropdown/select - List

I've been searching for an answer to this question for quite some time now, with no luck, or buggy solutions at max. The problem im facing is that i have a select element which (ob

Solution 1:

I think there is no way change event is gonna fire if the same item is selected. We were facing the same issue so what we did was a simple usability hack: When an item is selected we show to the user the item selected in a span and reset the value of dropdown to its default value (--Select--).

HTH

Solution 2:

this is maybe not excactly what do you want, but this another alternative that you can decide. after select the option, get it back to default(the empty one/first) option

<selectonchange="alert(this.value);this.value='';"><optionvalue=''selected='selected'></option><option>1</option><option>2</option><option>3</option></select>

or you can make

<selectonblur="alert(this.value);"><option>1</option><option>2</option><option>3</option></select>

but this way will call your function (alert) when user leave/blur/unfocus the list :p

Solution 3:

I was looking for the solution for the same scenario and ended up writing a angularjs directive for the same -

guthub link - angular select

Used element[0].blur(); to remove the focus off the select tag. Logic is to trigger this blur on second click of the dropdown.

as-select gets triggered even when user selects the same value in the dropdown.

DEMO - link

Post a Comment for "Select Already Selected Item In Dropdown/select - List"