Comments are available to members only. Sign up or Log in to view these comments.
Main Topics
Browse All TopicsI have come up with the follow code which lets the user type in the text box and the select box finds the closest first match. I have a part commented out which will actually highlight the part not typed (just in ie's address bar). It works fine, but when the select boxes get big *500+*(which in my application they are all) it takes a long time.
Is there a better way to do this, or can this be optimized somehow? If you have a better way of doing the same thing or can optimze it please responde
with the new code.
by the way i realize this in an IE only solution and that's ok. I only need it to work in IE.
However I need it to work. Honestly I'd like to just have a select box that worked EXACTLY like the type ahead in IE's address bar.
But I can't figure out how. I don't mind using Active X either. Like i said it only has to work in IE.
Thanks
my code follows:
============
<script language="javascript">
function findMatch(selectBox, txtFind, objEvent) {
if (objEvent.keyCode != 8) {
var i;
var s = "";
var st2 = new String(txtFind.value)
s2 = st2.toLowerCase()
for (i=0; i<selectBox.options.length
s = selectBox.options[i].text;
st = new String(s)
s = st.toLowerCase()
if (s.indexOf(s2) == 0) {
selectBox.selectedIndex = i;
//Selects the text. Commented out because it's too slow.
/*
var typed_string = new String(s2);
var total_string = new String(s);
var t = total_string.length - (total_string.length -
typed_string.length);
var end_string = total_string.substring(t, total_string.length);
txtFind.value = s
if (end_string != "" && end_string.length > 1) {
var range = txtFind.createTextRange();
range.findText(end_string)
range.select();
}
*/
return;
}
}
}
}
</script>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: chen_avinadavPosted on 2002-12-21 at 01:53:33ID: 7616854
Comments are available to members only. Sign up or Log in to view these comments.