468,117 Members | 1,581 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,117 developers. It's quick & easy.

Listbox selectindexchange not showing proper index value

I am using visual basic 2017 for a web application, I am using a listbox and I write a code for searching data and if I click on another index item (rather than last search)
listbox selectindexchange not showing last clicked index. my code are like that pleas tell me where I am wrong
Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox ID="TextBox21" runat="server" Onkeyup ="FilterItems(this.value)"  AutoPostBack ="True"
  2.  
  3. function FilterItems(value) {
  4.  
  5. ddl = document.getElementById("<%=ListBox1.ClientID %>");
  6.  
  7.         j1 = 0;
  8.         j = 1;
  9.         ok = 0;
  10.         if (ddl1 != null) 
  11.         {
  12.     for (i = 1; i < ddl1.options.length; i++) {
  13.                 ok = 0;
  14.  
  15.                 if(value.localeCompare((ddl1.options[i].innerHTML.substr(0, value.length))) !== 1) {
  16.                     if (value !== "") {
  17.                         ok = 1;
  18.                         j = i;
  19.  
  20.          ddl1.options[i].scrollIntoView(true);
  21.         ddl1.options[i].selected = true;
  22.         i = ddl1.options.length;
  23.         return false;
  24.  
  25.  
  26.                     }
  27.                 }
  28.             }
  29.          }
  30.            }
Dec 17 '19 #1
0 1696

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by michael | last post: by
3 posts views Thread by Chris Thunell | last post: by
5 posts views Thread by Stan SR | last post: by
reply views Thread by tedpottel | last post: by
13 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.