Начало
Формы
Эмуляция клавиши TAB
Пользователь может пойти в следующую область формы только, нажимая клавишу ENTER вместо клавиши TAB. Полезный с формой с 10 ключами введен. Какое экономящее время
Click enter in each field and watch as
it tabs to the next field for you. Wow!
Box 1:
Box 2:
Box 3:
Box 4:
JavaScript Forms: Эмуляция клавиши TAB
<!-- TWO STEPS TO INSTALL TAB KEY EMULATION: 1. Copy the coding into the HEAD of your HTML document 2. Add the last code into the BODY of your HTML document --> <!-- STEP ONE: Paste this code into the HEAD of your HTML document --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <! > <! > <!-- Begin nextfield = "box1"; // name of first box on page netscape = ""; ver = navigator.appVersion; len = ver.length; for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break; netscape = (ver.charAt(iln+1).toUpperCase() != "C"); function keyDown(DnEvents) { // handles keypress // determines whether Netscape or Internet Explorer k = (netscape) ? DnEvents.which : window.event.keyCode; if (k == 13) { // enter key pressed if (nextfield == 'done') return true; // submit, we finished all fields else { // we're not done yet, send focus to next box eval('document.yourform.' + nextfield + '.focus()'); return false; } } } document.onkeydown = keyDown; // work together to analyze keystrokes if (netscape) document.captureEvents(Event.KEYDOWN|Event.KEYUP); // End --> </script> </HEAD> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <center> <form name=yourform> Box 1: <input type=text name=box1 onFocus="nextfield ='box2';"><br> Box 2: <input type=text name=box2 onFocus="nextfield ='box3';"><br> Box 3: <input type=text name=box3 onFocus="nextfield ='box4';"><br> Box 4: <input type=text name=box4 onFocus="nextfield ='done';"><br> <input type=submit name=done value="Submit"> </form> </center> <!-- Script Size: 1.78 KB -->