I can think of several ways to improve the code below from Jeff S., or at least to reduce its line count by two or three.

function submitTrap3()
{
    var n = 0;
    var f =0;
    var elementItem = "";
    if (window.event.keyCode == 13)
    {
        for (n=0;n<document.forms[0].elements.length;n++)
        {
            elementItem = document.forms[0].elements[n].name;
            if ((document.forms[0].elements[n].value != "") &&
                (elementItem == trim(document.forms[0].txtControlName.value)))
            {
                switch (elementItem)
                {
                    case "header1:SearchBox" :
                    {
                        __doPostBack('header1:goSearch','');
                        break;
                    }
                    case "Text1":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text2":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text3":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text4":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text5":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text6":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text7":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text8":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text9":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text10":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text11":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text12":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text13":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text14":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text15":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text16":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text17":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text18":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text19":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text20":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text21":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text22":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text23":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text24":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text25":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text26":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text27":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text28":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text29":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text30":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text31":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text32":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text33":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text34":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text35":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text36":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text37":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text38":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text39":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text40":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text41":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text42":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text43":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text44":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text45":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text46":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text47":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text48":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text49":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                    case "Text50":
                    {
                        window.event.returnValue=false;
                        window.event.cancel = true;
                        document.forms[0].elements[n+1].focus();
                        break;
                    }
                }
            }
        }
    }
}

There's a pattern there. See if you can find it!

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!