See the attached image about a grid. It was setup for a customer to allow them to enter 20 work tickets at one time and then click submit.
They can use the "TAB" key to go from field to field as they do their data entry across the grid rows.
A new issue is that they want to use the "ENTER" key to go from field to field, in other words the "ENTER" key should act like "TAB" key on this screen, instead of doing a "submit".
I can't find anything in the WIKI about that or any grid properties that would or could change the "ENTER" key behavior.
Can some one point me in the right direction on how to accomplish this...or is it not possible?
Thanks,
mike
I did find 2 different sets of code on a way to do this, which follows. But I don't have a clue where to put it or how to use it. Any thoughts?
sample code 1:
function enterToTab(formRef, focusAny)
{
for(var i=0, e=formRef.elements, len=e.length, hasNext=true; i<len && hasNext; i++)
if( e[i].type && /^text|password|file|radio|select/.test( e[i].type ) )
{
for(var j=i+1; j<len && (!e[j].type ||( focusAny ? /hidden/.test(e[j].type): !/^text|password|file|radio|select/.test(e[j].type)) ); j++)
;
hasNext = j!=len;
e[i].onkeypress=new Function("var ta=false,k=(arguments[0]?arguments[0].which:window.event.keyCode )!=13;\
if(!k && !(ta=(this.type=='submit')))this.form.elements["+(j)+"].focus(); return k||ta;");
}
}
sample code 2:
function checkCR(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
if (!evt) return true;
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if (evt.keyCode == 13 && node && node.type=="text") {
evt.keyCode = 9; //tab
return true;
}
}
They can use the "TAB" key to go from field to field as they do their data entry across the grid rows.
A new issue is that they want to use the "ENTER" key to go from field to field, in other words the "ENTER" key should act like "TAB" key on this screen, instead of doing a "submit".
I can't find anything in the WIKI about that or any grid properties that would or could change the "ENTER" key behavior.
Can some one point me in the right direction on how to accomplish this...or is it not possible?
Thanks,
mike
I did find 2 different sets of code on a way to do this, which follows. But I don't have a clue where to put it or how to use it. Any thoughts?
sample code 1:
function enterToTab(formRef, focusAny)
{
for(var i=0, e=formRef.elements, len=e.length, hasNext=true; i<len && hasNext; i++)
if( e[i].type && /^text|password|file|radio|select/.test( e[i].type ) )
{
for(var j=i+1; j<len && (!e[j].type ||( focusAny ? /hidden/.test(e[j].type): !/^text|password|file|radio|select/.test(e[j].type)) ); j++)
;
hasNext = j!=len;
e[i].onkeypress=new Function("var ta=false,k=(arguments[0]?arguments[0].which:window.event.keyCode )!=13;\
if(!k && !(ta=(this.type=='submit')))this.form.elements["+(j)+"].focus(); return k||ta;");
}
}
sample code 2:
function checkCR(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
if (!evt) return true;
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if (evt.keyCode == 13 && node && node.type=="text") {
evt.keyCode = 9; //tab
return true;
}
}
Comment