Skip to main content
anvesh p が「#Visualforce」で質問
I want to remove focus from first field and want to set the focus on other field while the pages load. But below script doesnt work to set the cursor point on to  other field. can you please how can resolve in my custom visual force page.

<apex:page standardController="Opportunity"  extensions="OppStandardForcarePage">

<apex:sectionHeader title="Opportunity Edit"  subtitle="New Opportunity"/>

<!--<script type="text/javascript">

  window.onload = setFocus

  function setFocus() {

    document.getElementById("Ac").focus();

  }

</script>-->

<apex:form >

<script>

  function setFocusOnLoad()

  {

   document.getElementById("AcText").focus();    //see the id for account field below

  }

</script>

<apex:pageBlock title="Opportunity Edit" mode="edit">

<apex:actionRegion >

<apex:pageBlockSection title="Opportunity Information" columns="2" collapsible="2">

<apex:inputField value="{!Opp.AccountId}" taborderhint="1" id="AcText"/>
1 件の回答
  1. 2015年8月26日 17:54
    Hi ,

    Please try below code :

    <apex:page standardController="Opportunity"  extensions="OppStandardForcarePage">

    <apex:sectionHeader title="Opportunity Edit"  subtitle="New Opportunity"/>

    <apex:form >

    <apex:pageBlock title="Opportunity Edit" mode="edit">

    <apex:actionRegion >

    <apex:pageBlockSection title="Opportunity Information" columns="2" collapsible="2">

    <apex:inputField value="{!Opp.AccountId}" taborderhint="1" id="AcText"/>

    <script>

         document.getElementById("AcText").focus();    //see the id for account field below

    </script>

    <!--close other tags also- ->

    </apex:form>

    Please let me know if it will help you.

    Thanks,

    Vishal
0/9000