Auto Tab – unorthodox but simple

Usually tab indexes are hard coded. Problem is that if you have to insert a new element the tab indexes have to be reordered. This is a pain.

One way is to use indexes in steps of 2, 3 or 4 so that insertion is not a problem. The other way I use is as follows:

//top of view

<?php $tabIndex = 0; ?>

For typical Cake element:

<?php echo $form->text(‘Postajob.job_displaycontact’, array(‘class’ => ‘text’, ‘type’=>’checkbox’, ‘id’ => ‘job_displaycontact’, ‘tabindex’ => ++$tabIndex));?>

or in a non Cake environment:

<input …….. ‘tabindex’ = <?php echo ++$tabIndex; ?> />

This works well for sequential elements which is typically the case.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s