function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chuckwalleychuckwalley 

Controlling the cursor in a VF page

I am working on a VF page and want to control the cursor after I call the calcRevenue method in the controller. Currently, when the panel refreshes, the cursor is stuck at the upper left-hand of the screen. I want to tab through each field, change values, if necessary, then tab to the next field. I figure there is some javascript involved, but I'm not sure how to invoke it. 

 

Any help would be greatly appreciated. I'll even buy you a beer. 

 

<apex:outputPanel Id="GPS_Print_Area">
 <apex:PageBlockSection title="GPS Print Products" id="schedulePrintProducts_GPSD" columns="1" rendered="{!is_GPS_Distribution_OppRecType}" >
  <apex:pageBlocktable value="{!schedulePrintArray}" var="e_GPSD" style="width:100%" >
				
   <apex:column headerValue="Product"  >
    <apex:outputText styleClass="myClass"  value="{!e_GPSD.iProdName}" />
   </apex:column>
   <apex:column headerValue="Rate/Copy" Id="GPSD_RateCopy">
    <apex:inputField value="{!e_GPSD.iOLI.Rate__c}">
     <apex:actionSupport event="onchange" action="{!calcRevenue}" reRender="GPS_Print_Area">
     </apex:actionSupport>
    </apex:inputField>                         
   </apex:column>
   <apex:column headerValue="Avg Copies/Pub Day" Id="GPSD_AvgCopies">
    <apex:inputField value="{!e_GPSD.iOLI.AvgUnits__c}" >
     <apex:actionSupport event="onchange" action="{!calcRevenue}" reRender="GPS_Print_Area" />
    </apex:inputField>
   </apex:column>

   <apex:column headerValue="# Pub Days/Year" Id="GPSD_PubDays" >
    <apex:inputField value="{!e_GPSD.iOLI.DaysInTimePeriod__c}" >
     <apex:actionSupport event="onchange" action="{!calcRevenue}" reRender="GPS_Print_Area" />
   </apex:inputField>
  </apex:column>

  <apex:column headerValue="Contract Duration (Months)" Id="GPSD_Duration" >
   <apex:inputField value="{!e_GPSD.iOLI.Contract_Duration_Months__c}" >
    <apex:actionSupport event="onchange" action="{!calcRevenue}" reRender="GPS_Print_Area" />
   </apex:inputField>
  </apex:column>

  <apex:column headerValue="Projected Revenue" Id="GPSD_Revenue" >
   <apex:inputField value="{!e_GPSD.iOLI.UnitPrice}" >
						   
   </apex:inputField>
  </apex:column>
					
  <apex:column headerValue="Override" >
   <apex:inputField value="{!e_GPSD.iOLI.UnitPriceIsOverridden__c}" />
  </apex:column>					

  <apex:column headerValue="Start Date">
   <apex:inputField value="{!e_GPSD.iOLI.ServiceDate}" required="false" />
  </apex:column>

  

	
  </apex:pageBlocktable>
 </apex:PageBlockSection>
</apex:outputPanel>

 

Thanks, 

 

Chuck

 

Best Answer chosen by Admin (Salesforce Developers) 
neophyteneophyte

I assume your requirement is to focus on a field after the backed method is called. For this you can use Javascript.

 

1)The javascript function can be invoked after the function call using the attribute oncomplete

    <apex:actionSupport event="onchange" action="{!calcRevenue}" reRender="GPS_Print_Area"  oncomplete="ourJsFn()"/>

2)In the javascript function you can get the field you want to focus using

   var requriedField = document.getElementById(idOf theFieldYouWantToFocus);

3)After getting the field, you can actually focus on the field using requiredField.focus() method.

4)You can also change the value of the field using requriedField.value='changedValue';

All Answers

neophyteneophyte

I assume your requirement is to focus on a field after the backed method is called. For this you can use Javascript.

 

1)The javascript function can be invoked after the function call using the attribute oncomplete

    <apex:actionSupport event="onchange" action="{!calcRevenue}" reRender="GPS_Print_Area"  oncomplete="ourJsFn()"/>

2)In the javascript function you can get the field you want to focus using

   var requriedField = document.getElementById(idOf theFieldYouWantToFocus);

3)After getting the field, you can actually focus on the field using requiredField.focus() method.

4)You can also change the value of the field using requriedField.value='changedValue';

This was selected as the best answer
chuckwalleychuckwalley

Thank you. You are owed, one beer!