asp.net - Javascript & Listbox Item Removal -


i've got simple aspx page listbox, textbox , button. listbox loaded @ page_load event 40 or items.

the button fires off following javascript, supposed remove listbox item not contain value typed user in textbox. basically, it's supposed search tool.

problem is, removes half of items should. have click button 4 times results should have gotten on first click. here's function:

function search() { var strsearch = document.getelementbyid("<%= txtsearch.clientid %>").value; var lstrsns = document.getelementbyid("<%= lstreasons.clientid %>"); var temp; var i;  for(i=0;i<lstrsns.options.length;i++)     {     temp = lstrsns.options[i].text.touppercase();     if (temp.indexof(strsearch.touppercase()) == -1)         {         lstrsns.remove(i);         }                 } } 

what doing wrong? seems should work.

thanks any/all advice,

jason

the list keeps shortening remove elements.. lstrsns.remove(0); in loop until hit 1 you're looking , after lstrsns.remove(1);.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -