+ Start a Discussion
Eric Anderson 54Eric Anderson 54 

calendar autosspawns in visualforce

Hi there,

I have a Visualforce page that allows for editing of rows in a table. My problem is, I can't figure out what is causing the 'forcus' to be initially placed on the calendar of the first row of my visualforce object, and consiquently causing the calendar to display. I don't want the calednar to display unless someone clicks on it. My visualforce code is below, and a screenshot is attached.

Thank you in advance for your assistance.

<apex:page standardController="Request__c" extensions="TrController" >
    <!--Because we will be defining 'Input' fields, we must wrap our code in a 'Form' block. -->
    <apex:form id="Time_Entry_Form">
        <apex:pageBlock title="CDCR - Salesforce Time Reporting for Requests" id="Time_Entry_List">
           
            <!-- The following pageBlockButtons segment defines the two buttons that appear at the top of the Time entry form. -->
            <apex:pageBlockButtons id="Button_area">
                <!-- The following Button is defined in a more complicated fashion so that a parameter can be passed. -->
                <apex:commandLink >
                    <a href="javascript: CurrRequest('{!Request__c.Id}');" class="btn">New</a>               
                </apex:commandLink>
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
           
             <!-- The following pageBlockTable segment defines the time entry rows that will be displayed. -->
            <apex:pageBlockTable value="{!TimeEntries}" var="entry" id="Entry_Table_List">
                <apex:column width="45" headerValue="Action">
                    <a href="javascript:if (window.confirm('Are you sure?')) DeleteEntry('{!entry.Id}');" style="font-weight:bold">Del</a>               
                </apex:column>   
                <apex:column width="70" headerValue="Activity">
                    <apex:inputField value="{!entry.Activity__c}"/>
                </apex:column>   
                <apex:column headerValue="Date Worked">
                    <apex:inputField value="{!entry.Date_Worked__c}"/>
                </apex:column>   
                <apex:column width="20" headerValue="Hours">
                    <apex:inputField value="{!entry.Hours_Worked__c}"/>
                </apex:column>   
                <apex:column width="20" headerValue="Worked">
                    <apex:inputField value="{!entry.Minutes_Worked__c}"/>
                </apex:column>   
                <apex:column headerValue="Work Description">
                    <apex:inputField style="width:100%" value="{!entry.Work_Description__c}"/>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
        <!-- This action block is executed based on the 'Delete' button being clicked on. -->
        <apex:actionFunction action="{!del}" name="DeleteEntry" reRender="Time_Entry_List">
            <apex:param name="EntryID" value="" assignTo="{!SelectedEntryID}"/>
        </apex:actionFunction>
       
         <!-- This action block is executed based on the 'New' button being clicked on. -->
        <apex:actionFunction action="{!add}" name="CurrRequest" reRender="Time_Entry_List">
            <apex:param name="EntryID" value="" assignTo="{!ReqID}"/>
        </apex:actionFunction>

    </apex:form>
</apex:page>

User-added image
VivekShindeVivekShinde
You can set focus to the save button when the page loads for the first time. You need to provide id to the save button and write the below code:
<apex:pageBlockButtons id="Button_area">
            <!-- The following Button is defined in a more complicated fashion so that a parameter can be passed. -->
            <apex:commandLink >
                    <a href="javascript: CurrRequest('{!Request__c.Id}');" class="btn">New</a>               
            </apex:commandLink>
            <apex:commandButton value="Save" action="{!save}" id="saveButtonId"/>
            <script>
                    document.getElementById('{!$Component.saveButtonId}').focus();
            </script>
</apex:pageBlockButtons>
Let me know if this works.