00794: automatic tabindexing of form elements

Summary: automatic tabindexing of form elements
Created: 2006-08-25 09:38
Status: Open
Category: Feature
Priority: 4
Version: 2

Description: Form elements have a "tabindex" property that allows an author to specify the order in which the cursor will move to them when the user presses the tab key. Without tabindexes, a user must either use the mouse to click on the first field of the form or press tab for every single link on the page until the cursor finally reaches the form.

Manually assigning tabindexes in a large form, particularly with lots of checkboxes, is a tedious process, and unless you have the forethought to assign them in multiples of 5 or 10, you may have to renumber them all later when you add a field to the form!

I believe this is an analogous situation to an ordered list: HTML allows us to mark each item simply as a list item, and the numbering is done automatically. So it should be with tabindexes, unless we specify otherwise!

I propose modifying forms.php so that when an (:input:) tag specifies a tabindex, all subsequent (:input:) tags will be automatically assigned tabindexes. Specifying another tabindex lower in the page will reset the counter to that number, and defining tabindex=0 will stop the counter.

I have implemented this successfully... The code is as follows:

 //automatic tabindex
 if ($opt['tabindex']>0) {
  $InputTabIndex = $opt['tabindex']+1;
 } elseif ($opt['tabindex']===0) {
  $InputTabIndex = 0;
 } elseif (($InputTabIndex > 0) and ($type!='form') and ($type != 'end') and ($type != 'hidden')) {
  $opt['tabindex'] = $InputTabIndex++;

(Where $InputTabIndex is a global variable.)

Ben Stallings August 25, 2006, at 09:38 AM