Hola,
Pues hablamos de municipios de una provincia, supongo que lo que relentiza el proceso es parsear el string para sacar las options, te posteo el código JavaScript que he utilizado:
Código PHP:
function select_innerHTML(objeto,innerHTML){
/******
* select_innerHTML - innerHTML to add option(s) to select(s)
* Problem: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
* Creative Commons license
* Versão: 1.0 - 06/04/2006
* Author: Micox - Náiron J.C.G - [email protected] - elmicoxcodes.blogspot.com
* Parametros:
* objeto(tipo object): the select
* innerHTML(tipo string): the new innerHTML
*******/
objeto.innerHTML = ""
//creating phantom element to receive temp innerHTML
var selTemp = document.createElement("micoxselect")
var opt;
selTemp.id="micoxselect1"
document.body.appendChild(selTemp)
selTemp = document.getElementById("micoxselect1")
selTemp.style.display="none"
if(innerHTML.toLowerCase().indexOf("<option")<0){//if not option, convert do option
innerHTML = "<option>" + innerHTML + "</option>"
}
innerHTML = innerHTML.replace(/<option/g,"<span").replace(/</option/g,"</span")
selTemp.innerHTML = innerHTML
//transfering childs of phantom element to options
for(var i=0;i<selTemp.childNodes.length;i++){
if(selTemp.childNodes[i].tagName){
opt = document.createElement("OPTION")
for(var j=0;j<selTemp.childNodes[i].attributes.length;j++){
opt.setAttributeNode(selTemp.childNodes[i].attributes[j].cloneNode(true))
}
opt.value = selTemp.childNodes[i].getAttribute("value")
opt.text = selTemp.childNodes[i].innerHTML
if(document.all){ //IEca
objeto.add(opt)
}else{
objeto.appendChild(opt)
}
}
}
//clear phantom
document.body.removeChild(selTemp)
selTemp = null
}