You need to sign in to do that
Don't have an account?
sanca
Getting custom checkbox value ( not related to object) in apex
Hello All ,
I have designed a sample action function method to a call controller from JS and its working fine.But I need to do an enhancement like if checkbox is unselected the output text should not be rendered ( currenlty , once if the checkbox is selected , it remains forever) . Please help me ,below is the code.
P.S : Check box is not part of object , its just custom checkbox which is created in VF page
Visualforce
------------------
Public class Actionfunction {
Public string MyString_From_Methode{get;set;}
public Actionfunction(ApexPages.StandardController controller) {
}
public string ActionFunMethode(){
MyString_From_Method = 'Method called from js using Action function';
return null;
}
}
Apex :
--------
<apex:page standardcontroller="Account" extensions="Actionfunction" tabStyle="Account">
<apex:form >
<apex:actionFunction name="actionFunName" action="{!ActionFunMethod}" reRender="outputtxtId"/>
<apex:pageBlock >
<apex:outputLabel for="inptCheckBox" value="Check this box to call Controller method from js using ActionFunction" style="color:green;"></apex:outputLabel>
<apex:inputcheckbox onclick="javaScrpt()" id="inptCheckBox" />
</apex:pageBlock>
<apex:outputText value="{!MyString_From_Methode}" id="outputtxtId" ></apex:outputText>
</apex:form>
<script>
function javaScrpt(){
actionFunName();
}
</script>
</apex:page>
I have designed a sample action function method to a call controller from JS and its working fine.But I need to do an enhancement like if checkbox is unselected the output text should not be rendered ( currenlty , once if the checkbox is selected , it remains forever) . Please help me ,below is the code.
P.S : Check box is not part of object , its just custom checkbox which is created in VF page
Visualforce
------------------
Public class Actionfunction {
Public string MyString_From_Methode{get;set;}
public Actionfunction(ApexPages.StandardController controller) {
}
public string ActionFunMethode(){
MyString_From_Method = 'Method called from js using Action function';
return null;
}
}
Apex :
--------
<apex:page standardcontroller="Account" extensions="Actionfunction" tabStyle="Account">
<apex:form >
<apex:actionFunction name="actionFunName" action="{!ActionFunMethod}" reRender="outputtxtId"/>
<apex:pageBlock >
<apex:outputLabel for="inptCheckBox" value="Check this box to call Controller method from js using ActionFunction" style="color:green;"></apex:outputLabel>
<apex:inputcheckbox onclick="javaScrpt()" id="inptCheckBox" />
</apex:pageBlock>
<apex:outputText value="{!MyString_From_Methode}" id="outputtxtId" ></apex:outputText>
</apex:form>
<script>
function javaScrpt(){
actionFunName();
}
</script>
</apex:page>
https://developer.salesforce.com/page/Wrapper_Class
Please let us know if this will help you