added proxy to to add options to a selectbox, needed by IE

This commit is contained in:
Ralf Becker 2005-06-11 19:06:38 +00:00
parent 82a6c07021
commit 4693d2c6b4

View File

@ -75,3 +75,26 @@ function activate_tab(tab,all_tabs,name)
set_element(document.eTemplate,name,tab);
}
}
/* proxy to to add options to a selectbox, needed by IE, but works everywhere */
function selectbox_add_option(id,label,value,do_onchange)
{
selectBox = document.getElementById(id);
for (i=0; i < selectBox.length; i++) {
if (selectBox.options[i].value == value) {
selectBox.options[i].selected = true;
break;
}
else if (value.slice(0,1) == "," && selectBox.options[i].value.slice(0,1) == ",") {
selectBox.options[i].value = value;
selectBox.options[i].text = "multiple*";
selectBox.options[i].title = label;
selectBox.options[i].selected = true;
break;
}
}
if (i >= selectBox.length) {
selectBox.options[selectBox.length] = new Option(label,value,false,true);
}
if (selectBox.onchange && do_onchange) selectBox.onchange();
}