var txtValue = document.getElementById('<%=TextBox1.ClientID %>').value; var lstbox = document.getElementById('<%=ListBox1.ClientID %>'); var opt; var array = new Array(); var array1 = new Array(); array = lstbox.options; if (txtValue != '') { for (var i = 0; i < array.length; i++) { if (array[i].text.toLowerCase().indexOf(txtValue) != -1) { opt = document.createElement("option"); opt.text = array[i].text; opt.value = array[i].value; array1.push(opt); } } lstbox.options.length = 0; for (var i = 0; i < array1.length; i++) { opt = document.createElement("option"); opt.text = array1[i].text; opt.value = array1[i].value; lstbox.add(opt); } } else { lstbox.options.length = 0; for (var i = 0; i < array.length; i++) { opt = document.createElement("option"); opt.text = array[i].text; opt.value = array[i].value; lstbox.add(opt); } } }
sravan
Mark This Response as Answer -- Chandu http://www.dotnetfunda.com/images/dnfmvp.gif
Login to post response