+ Start a Discussion
rajasfdcrajasfdc 

why we use tabindex?

why we use tabindex?how it used for us.in coding ?i need syntax of this.

Suresh RaghuramSuresh Raghuram

for example you have 10 input text or some other fields. If the user wants to move from the 1 st field on the first column and then the 1 st field on the second column, then to the 2 nd field in 1 st column when he clicks the tab button on key board

 

code sample is

<apex:commandButton action="{!save}" rendered="{!!dupeCheck}" title="Save" value="Save" id="tabIndex5000"/>
                <apex:commandButton action="{!cancel}" title="Cancel" value="Cancel" id="tabIndex5100"/>

 

In this example it moves from save button to cancel button

If this answers your question mark it as solution

sfdcfoxsfdcfox

Previous poster almost had it correct, except the precise syntax.

 

First, a brief history.

 

The tab key allows users to move from field to field. Initially, the only way you could tab through a page was in source code order. With dynamic HTML and DOM trees, it became possible that the source order (or even the field creation order) might not be the same order that would ultimately be used to navigate through a page by use of the tab key. Surely you've seen at least one page where this effect is horribly annoying. 

 

HTML introduced a fix for this, known as tabindex. When focus lands on a tabindex element, all future uses of the tab key will go to the next tabindex field in index order (and possibly source order, if there is a tie), and only after all tabindexes are exhausted will the browser continue tabbing through all un-indexed elements. Once the user is back to the lowest index, the cycle repeats. Salesforce.com itself uses this internally on standard layouts when a page block section is defined as "top-down" tab style (as opposed to the left-right style).

 

So, with this in mind, you now know why you might use it (so you can control the tab order of a form or page). This is especially important on mobile devices, which typically offer a "next" button on their virtual keyboards (if applicable).

 

Usage is simple: simply apply tabIndex to all the elements you want to control the order of, keeping in mind that if you use the index even once, you can't have any gaps from one indexed field to the next, or they'll be skipped until all indexes are exhausted. It looks like this:

 

<apex:inputText tabIndex="3" value="{!somevar}"/>

Indexes start at zero and increment towards infinity (but you should probably avoid incredibly use indexes without reason). -1 is a special index that prohibits the user from tabbing into an element at all (they may only use the keyboard to enter or activate the element when it does not have focus).