Tutorials to .com

Tutorials to .com » Asp » Encoding » Return the form filled out when the realization of the way instead of TAB

Return the form filled out when the realization of the way instead of TAB

Print View , by: iSee ,Total views: 5 ,Word Count: 273 ,Date: Fri, 29 May 2009 Time: 8:32 PM

The key lies in tabindex, the design idea is: for each form element to set up a tabindex, the value of a form element before the tabindex value plus one, of its function is to function when the user press the Enter key when the first tabindex current value plus one, and then one by one with each form element values of the tabindex contrast, if the same will be moved to focus on the form elements.

First of all, we need to set a body in the form onkeyup event:
<form name="xxx" action="YYY.asp" method="post" onkeyup="return changefocus_onkeyup()" language="javascript">

Second, in every form element to set a tabindex value, it is assumed that there are three elements of the form, then we set the tabindex values were as follows:
<input type=text name="txtName" size="16" tabindex=1>
<input type=checkbox name="chkSign" tabindex=2>
<textarea name="tarContent" tabindex=3>

Finally, write changefocus function as follows:
function newinfo_form_onkeyup ()
(
key = window.event.keyCode;
if (key == 0xD) / / determine whether the press the Enter key
(
CurTabIndex = event.srcElement.tabIndex +1 / / the current value of the tabindex plus 1
for (n = 0; n <newinfo_form.elements.length; n + +)
(
if (newinfo_form.elements [n]. tabIndex == CurTabIndex) / / find the next form element
(
newinfo_form.elements [n]. focus (); / / move the focus of
return true;
)
)
)
)


Asp Script encoding Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.