Click to See Complete Forum and Search --> : Custom disabling of SELECT element


dlsingh
02-06-2003, 09:38 AM
I have a form that is poplulated with a dataset ONLOAD, and uses JavaScript to highlight any data items that are flagged as dirty (updated). I want all the form elements to be read-only, which works fine for <input> elements, but the <select> element doesn't have any sort of READONLY property. If I use the DISABLED property on the SELECT elements I cannot apply the highlighting because the DISABLED property overrides any style settings you apply.


So my question is does anyone know a way to either:

A) Override the style which the browser uses to render DISABLED <select> elements

OR

B) Some other way (Javascript, DHTML, ...) to make a <select> element appear to be read-only

C) any other suggestion you might have.


Luckily the pages are coded specifically for IE 6 so I don't have to worry about compatibility issues if you have a workaround...

Zach Elfers
02-06-2003, 12:54 PM
Try this:

<select name="select1" onChange="return false;" style="background-color:#008800;">
<option selected>This is selected</option>
<option>Bet you can't select this...</option>
<option>...or this...</option>
</select>