/    Sign up×
Community /Pin to ProfileBookmark

Dynamic Select List

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);
}

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@MrNobodyDec 30.2008 — Try:

pSelect.options.length = 0;
×

Success!

Help @rmagan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...