Author Topic: How to set focus on the next input text field  (Read 5643 times)

Offline admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 296
    • View Profile
How to set focus on the next input text field
« on: March 08, 2011, 01:43:45 PM »
This function can set the next input text field focused:
Code: [Select]
function SetNextCellFocus(source) {
    var lastFocusCellName = source.name;

    var els = document.getElementsByTagName("INPUT");
    var lLength = els.length;
    for (var i = 0; i < lLength; i++) {
        if (els[i].name != null) {
            if (els[i].name == lastFocusCellName && i + 1 < lLength) {
                try {
                    els[i + 1].focus();
                    els[i + 1].select();
                }
                catch (err) { }
                finally {
                    break;
                }
            }
        }
    }


}