Need to get index of item in AutoCompleteExtender

I am just starting out in ajax.  I've figured out how to get the items I need to fill a list in the AutoExtendControl attached to a textbox.  That part works fine, and I'm able to enter text, see the drop-down, and then select an item to fill out the textbox.  But I am trying to find a quick way to access the index (integer) of the item selected from the list.  I need this in order to search a separate list for the same index in order to pull values into other places on the page.  
Who is Participating?
1: add hidden field next to your serach textbox
                    <asp:HiddenField ID="SelectedItemValue" runat="server" />
2: register onchange event to your listbox
                     listbox.Attributes.Add("onchange", String.Format("javascript:SelectItem(this,  '{0}');", SelectedItemValue.ClientID);
3: Create a javascript function where you copy the listbox selected value into the hidden field.
                     function SelectItem(listElement, hdnField)
                        document.getElementById(hdnField).value = listElement.options[listElement.selectedIndex].value

then you should have the selected value in hidden field for later use.

Hope this helps!
RinaXAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.