Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox Connected to ListBox (Dynamic) 1

Status
Not open for further replies.

MarciaG

MIS
May 16, 2000
4
US
Would like a Listbox filled from database with employee names and then a textbox that is connected with it that scrolls to the name in the list that corresponds with the letters being typed in the text box.  I realize that I will have to have a recordset located on the client or use an array of some kind.  Does anyone have any ideas or know of some sample code?
 
here is a generic idea about how this could be done,<br><br>1. the listbox is build from the database (some server side code is needed - ASP, PHP ... Everything else is done on the client side)<br>2. the text-box value is examined by onkeyup event and its value is compared to the values in the listbox array, when first match is found the selectedIndex property of the listbox is set.<br><br>if you would like a working example,please contact me with more details.<br><br>IvanP<br>(<A HREF="mailto:ip@thehyper.net">ip@thehyper.net</A>)<br>
 
Thank You IvanP.<br><br>1) The ASP side is done.<br><br>2) It is the client side that I am having trouble with:<br>&nbsp;&nbsp;&nbsp;This is what I have so far for my function which is called from the textbox onkeyup event.<br><br>function NameChg(){<br>&nbsp;&nbsp;var selecttxt = new String(document.empform.EmpNum.options.value);<br>&nbsp;&nbsp;var searchtxt = document.empform.SearchEmp.value<br>&nbsp;&nbsp;var subselecttxt = selecttxt.substr(0,1)<br>&nbsp;&nbsp;var myRegExp = /searchtxt/;<br>&nbsp;&nbsp;if (subselecttxt = myRegExp){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.empform.EmpNum.selectedIndex = selecttxt.selectedIndex;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;}<br>I guess what I need is to loop through the array on each keyup event and add the next letter to the search?<br><br>Any ideas?<br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top