Hello
I'm writing some javascript that will allow our users to navigate through the fields of a webpage using their keyboard and either the enter or down arrows in addition to the default tab keystroke. This is working great however there are some quirks when it comes to the combobox, as hitting down it should select the next item and not jump out. Instead it is doing both and even after switching fields it leaves the combobox open. Much like I did for the radiogroup I wanted to make it so down would cycle through each option until the last when it would break out of the combobox and onto the next control. I have been unable to do this as the javascript type is always returned as text, I assume this is because behind the scenes the rad combobox is actually a set of stacked text fields. That's all fine and dandy however I need a way to distinguish this control from other control types.
Here's some sample code:
document.onkeydown = function (e) {
e = e || window.event;
if (typeof e != 'undefined') {
var tgt = e.target || e.srcElement;
// If the keypress was ENTER (13) or DOWN (40)
if (e.keyCode == 13 || e.keyCode == 40) {
// Determine which element we're currently on
currentField = e.target;
alert(currentField.type);
}
}
}
I stripped out most of the logic here, all it's doing is listening for a keypress and if it's enter or down it will show the control type. As already said I'm getting "text" for a combobox which leave same with no way to identify it (without knowing the name ahead of time,which isn't an option here).
So my questions is: is there a way to get the type of the combobox control through JavaScript? Or is this a bug in the telerik controls that needs to be fixed?
Thanks in advance :)
I'm writing some javascript that will allow our users to navigate through the fields of a webpage using their keyboard and either the enter or down arrows in addition to the default tab keystroke. This is working great however there are some quirks when it comes to the combobox, as hitting down it should select the next item and not jump out. Instead it is doing both and even after switching fields it leaves the combobox open. Much like I did for the radiogroup I wanted to make it so down would cycle through each option until the last when it would break out of the combobox and onto the next control. I have been unable to do this as the javascript type is always returned as text, I assume this is because behind the scenes the rad combobox is actually a set of stacked text fields. That's all fine and dandy however I need a way to distinguish this control from other control types.
Here's some sample code:
document.onkeydown = function (e) {
e = e || window.event;
if (typeof e != 'undefined') {
var tgt = e.target || e.srcElement;
// If the keypress was ENTER (13) or DOWN (40)
if (e.keyCode == 13 || e.keyCode == 40) {
// Determine which element we're currently on
currentField = e.target;
alert(currentField.type);
}
}
}
I stripped out most of the logic here, all it's doing is listening for a keypress and if it's enter or down it will show the control type. As already said I'm getting "text" for a combobox which leave same with no way to identify it (without knowing the name ahead of time,which isn't an option here).
So my questions is: is there a way to get the type of the combobox control through JavaScript? Or is this a bug in the telerik controls that needs to be fixed?
Thanks in advance :)