Making a multi-line select box read-only in HTML
Is there a way I can make an HTML multiple select box 开发者_如何学运维read-only? I want to have the scrolling capability, but I don't want to allow selections to be made.
Figured it out right after I posted -- The correct way of maintaining scrolling functionality while disabling selection is to disable each option:
<select MULTIPLE name="WG_Emp_List" class="mainText" readonly="readonly">
<cfloop query="Agent_List">
<cfoutput><option disabled>#LAST_NAME#, #FIRST_NAME#</option></cfoutput>
</cfloop>
</select>
<select onchange="this.selectedIndex = 1">
<option value="Foo">Foo</option>
<option value="Bar" selected="selected">Bar</option>
</select>
You can read about it here.
精彩评论