Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent select dropdown to open but allow its events to fire

Is there any way I can trap html select events, and prevent the html select dropdown to open? (Disabling html select is ruled out since the events will be disabled too.)

like image 457
deepak Avatar asked Dec 15 '09 06:12

deepak


2 Answers

I doubt this will actually prevent it from opening, but it will ensure that the DropDown will always maintain the same value:

<select name="theselect" onchange="this.selectedIndex = 1;">
    <option value="Red">Red</option>  
    <option value="Green" selected="selected">Green</option>  
    <option value="Blue">Blue</option> 
</select>
like image 89
Dominic Barnes Avatar answered Sep 23 '22 02:09

Dominic Barnes


This doesn't disable the "dropdown to open", but if you don't want anything selectable, a trick I used was to make <optgroup> instead of option. However, I'm confused why you would want to disable the dropdown, but disabling it is not option...

like image 20
Myles Avatar answered Sep 24 '22 02:09

Myles