Hello. This is my second post.
The non-DOM property innerHTML can't add options to a tag select in Internet Explorer.
Example not working:
document.getElementById("my_select").innerHTML = " ";
The correct way to insert options in a select is using appendChild or addOption functions. But that's tiring if we are working with Ajax.
Use innerHTML is not the standard but it is very useful.
The function above, will help you to insert options like using innerHTML, in IE, Firefox or Opera.
Updated: now supports option-selected
Using my function:
var inner = " ";
select_innerHTML(document.getElementById("my_select"),inner);
The function. Add to your lib.
function select_innerHTML(objeto,innerHTML){
/******
* select_innerHTML - corrige o bug do InnerHTML em selects no IE
* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
* Versão: 2.1 - 04/09/2007
* Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br
* @objeto(tipo HTMLobject): o select a ser alterado
* @innerHTML(tipo string): o novo valor do innerHTML
*******/
objeto.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("
No comments:
Post a Comment