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)
}
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)
}