actionFunction: A component that provides support for invoking controller action methods directly from JavaScript code using an AJAX request. An <apex:actionFunction> component must be a child of an <apex:form> component.
Example:
<apex:page controller="actionFunctionController" tabStyle="Account">
<apex:form >
<apex:actionFunction name="priorityChangedJavaScript" action="{!priorityChanged}" rerender="out"/>
<apex:pageBlock >
<apex:pageBlockSection title="If you will select High Customer Priority then phone textbox will be shown" columns="1" id="out" collapsible="false">
<apex:inputField value="{!acc.CustomerPriority__c}" onchange="priorityChangedJavaScript()"/>
<apex:inputField value="{!acc.Phone}" rendered="{!showPhone}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class actionFunctionController {
public Account acc{get;set;}
public Boolean showPhone{get;set;}
public actionFunctionController(){
acc = new Account();
showPhone = false;
}
public PageReference priorityChanged(){
if(acc.CustomerPriority__c == 'High'){
showPhone = true;
}
else{
showPhone = false;
}
return null;
}
}
actionFunction: A component that provides support for invoking controller action methods directly from JavaScript code using an AJAX request. An <apex:actionFunction> component must be a child of an <apex:form> component.
Example:
<apex:page controller="actionFunctionController" tabStyle="Account">
<apex:form >
<apex:actionFunction name="priorityChangedJavaScript" action="{!priorityChanged}" rerender="out"/>
<apex:pageBlock >
<apex:pageBlockSection title="If you will select High Customer Priority then phone textbox will be shown" columns="1" id="out" collapsible="false">
<apex:inputField value="{!acc.CustomerPriority__c}" onchange="priorityChangedJavaScript()"/>
<apex:inputField value="{!acc.Phone}" rendered="{!showPhone}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class actionFunctionController {
public Account acc{get;set;}
public Boolean showPhone{get;set;}
public actionFunctionController(){
acc = new Account();
showPhone = false;
}
public PageReference priorityChanged(){
if(acc.CustomerPriority__c == 'High'){
showPhone = true;
}
else{
showPhone = false;
}
return null;
}
}
actionFunction:
A component that provides support for invoking controller action methods directly from JavaScript code using an AJAX request. An <apex:actionFunction> component must be a child of an <apex:form> component.
Example:
Also, refer the below links:
http://sfdcsrini.blogspot.com/2014/07/visualforce-action-function-example.html
https://success.salesforce.com/answers?id=90630000000hU2kAAE
https://developer.salesforce.com/forums/?id=906F0000000BTIPIA4
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionFunction.htm
Hope this helps you!
Best Regards,
Deepthi
All Answers
actionFunction:
A component that provides support for invoking controller action methods directly from JavaScript code using an AJAX request. An <apex:actionFunction> component must be a child of an <apex:form> component.
Example:
Also, refer the below links:
http://sfdcsrini.blogspot.com/2014/07/visualforce-action-function-example.html
https://success.salesforce.com/answers?id=90630000000hU2kAAE
https://developer.salesforce.com/forums/?id=906F0000000BTIPIA4
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionFunction.htm
Hope this helps you!
Best Regards,
Deepthi