You need to sign in to do that
Don't have an account?
Visualforce taborder - How to set focus on the first field if it is a picklist field?
I have noticed that in a VF page if you have a picklist field as your first field the initial field set to focus is the first non-picklist field. This is undesireable and odd as I want the user's tab-focus to be on the first field of the page.
has anyone else noticed this and know a way to achieve the desired (expected) result? I have already tried setting focus to the field in question via js but it seems to be ignored or some other script included by SFDC is being run to set the tab index to the first non-picklist field.
Thanks in advance to all those who view/help.
Solved this by using the accepted standard workaround for similar issues:
At the top of the page I overwrote the SetFocusOnLoad JS function and then elsewhere in my code I explicitely set focus to the first field via the Focus() js function.
All Answers
Solved this by using the accepted standard workaround for similar issues:
At the top of the page I overwrote the SetFocusOnLoad JS function and then elsewhere in my code I explicitely set focus to the first field via the Focus() js function.
i have noticed a problem like u and now i got the answer .If the showheader is true ,visualforce inbuilt javascript will run while load the page.in that time we cannot use window.onload. hence it automatically focus the first non picklist field by inbuilt javascript.
To overcome those rules we have to write some java scripts like here:
It will work even showheader is true,,,,
<script>
function setFocusOnLoad(){ call.focus(); }
</script>
write the above code to the header.
and
<script>
var call = document.getElementById('{!$Component.fieldId}')
</script>
write above code where the inputfield is coded, or my example is
Example:::
<apex:page standardController="user" sidebar="false" showHeader="true" id="p">
<script>
function setFocusOnLoad(){ mass.focus();}
</script>
<apex:form id="theForm" >
<apex:pageBlock id="block">
<apex:pageBlockSection id="sec" >
<apex:pageBlockSectionItem id="item">
<apex:outputLabel value="Company Name"> </apex:outputLabel>
<apex:inputField value="{!us.Companyname}" id="maas" taborderhint="2" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<script>
var mass=document.getElementById('{!$Component.theForm.block.sec.item.maas}');
</script>
</apex:page>
i mentioned only one field here but it will work if many field presence and also focus picklist also,,,,,
thank you,,,,