Código HTML:
<html> <head> <script type="text/javascript"> function ativaOptionsDisabled(){ var sels = document.getElementsByTagName('select'); for(var i=0; i < sels.length; i++){ sels[i].onchange= function(){ //pra se mudar pro desabilitado if(this.options[this.selectedIndex].disabled){ if(this.options.length<=1){ this.selectedIndex = -1; }else if(this.selectedIndex < this.options.length - 1){ do { this.selectedIndex++; } while(this.options[this.selectedIndex].disabled && this.selectedIndex < (this.options.length-1)); if(this.options[this.selectedIndex].disabled) { do { this.selectedIndex--; } while(this.options[this.selectedIndex].disabled && this.selectedIndex > -2); } }else{ do { this.selectedIndex--; } while(this.options[this.selectedIndex].disabled && this.selectedIndex > -2); } } } if(sels[i].options[sels[i].selectedIndex].disabled){ //se o selecionado atual é desabilitado chamo o onchange sels[i].onchange(); } for(var j=0; j < sels[i].options.length; j++){ //colocando o estilo if(sels[i].options[j].disabled){ sels[i].options[j].style.fontWeight = 'bolder'; sels[i].options[j].style.color = 'black'; } } } } window.attachEvent("onload", ativaOptionsDisabled); </script> </head> <body onload='ativaOptionsDisabled()'> <select name="id_tema" class="campos" id="id_tema" onChange="comprobar(this)"> <option value="" selected="selected">-- Seleccione --</option> <option value="1">Tarifaria y Fiscal</option> <option value="2">Instalación</option> <option value="3" disabled="disabled" class="disa">-----------------------------------</option> <option value="4" disabled="disabled" class="disa">Operados por Risen</option> <option value="4" disabled="disabled" class="disa"></option> <option value="2">Barcelona (BCN)</option> </select> </body> </html>
Gracias!