I have a select list on a page that is geting values from database. When user clicks on select list, I want it to wipe out the values that were there and select whatever is current from database. I am using code below, but this seems to be looping thru all the entries in the select list (see appendToSelect) and taking a long amount of time to execute. Is there an easier way to wipeout all the entries in the select list 1st (besides looping)
onmousedown=”get_select_list_xml1(this,this,this,this);”
<script>
function get_select_list_xml1(pPkid,pSchool,pYear,pSelect){
var l_Return = null;
var l_Select = html_GetElement(pSelect);
var get = new htmldb_Get(null,html_GetElement(‘pFlowId’).value,
‘APPLICATION_PROCESS=REFRESH_ATTENDANCE_CODE_LOV’,0);
gReturn = get.get(‘XML’);
if(gReturn && l_Select){
var l_Count = gReturn.getElementsByTagName(“option”).length;
l_Select.length = 0;
for(var i=0;i<l_Count;i++){
var l_Opt_Xml = gReturn.getElementsByTagName(“option”)[i];
appendToSelect(l_Select, l_Opt_Xml.getAttribute(‘value’),
l_Opt_Xml.firstChild.nodeValue)
}
}
get = null;
}
function appendToSelect(pSelect, pValue, pContent) {
var l_Opt = document.createElement(“option”);
l_Opt.value = pValue;
if(document.all){
pSelect.options.add(l_Opt);
l_Opt.innerText = pContent;
}else{
l_Opt.appendChild(document.createTextNode(pContent));
pSelect.appendChild(l_Opt);
}