Search Text in a select box ...

D

Dirk Laurenz

Hello everybody,

i really confused now..
i want to catch each key, when a select box has a focus. composing the
search phrase is no problem.
but when i want to search within the select box i get always the same
error:

"Selectbox.options has no properties"

But it is no problem to alert Selectbox.options.text oder .value.

Here's my code:


..js file:
---------------------------------
var CharCountIndex=0;
var InputCharList="";
var KeyTimeOut;
function SelectElementByChar(e,SelectBox) {
clearTimeout(KeyTimeOut);
if(window.event) // IE
{
keynum = e.keyCode
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which
}
// keycode must be between 65-90 or 97-122
character = String.fromCharCode(keynum).toLowerCase();
if (keynum>64 && keynum<91) {
CharCountIndex++;
InputCharList = InputCharList + character;

document.change_group.debug2.value=InputCharList;
}
if (keynum >96 && keynum <123) {
CharCountIndex++;
InputCharList = InputCharList + character;

document.change_group.debug2.value=InputCharList;
}
if (keynum == 46) {
CharCountIndex++;
InputCharList = InputCharList + character;

document.change_group.debug2.value=InputCharList;
}
document.change_group.debug1.value=SelectBox.name;
if (InputCharList.length >1) {
for (i==0; i<=SelectBox.length; i++)
{
// ----this is complained about

TextToCompare=String(SelectBox.options.value);
FindIndex=TextToCompare.indexOf(InputCharList);
if (FindIndex!=-1) {
SelectBox.selected=true;
}
}
}
KeyTimeOut=window.setTimeout("ResetVars()", 1000)
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top