", "answerCount": 1, "upvoteCount": 0, "datePublished": "2015-07-06T08:57:08.000Z", "author": { "@type": "Person", "name": "sanju C A", "url": "https://trailblazers.salesforce.com/profileView?u=00530000009YlznAAC", "affiliation": { "@type": "Organization", "name": "Cargill" } }, "suggestedAnswer": [ { "@type": "Answer", "text": "Please post this question in one of the developer forums for a quick response, this forum is more focussed towards the declarative side of things.   https://developer.salesforce.com/forums/#!/feedtype=RECENT&criteria=ALLQUESTIONS   http://salesforce.stackexchange.com/", "upvoteCount": 1, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A7bp2SAB", "datePublished": "2015-07-06T09:35:36.000Z", "author": { "@type": "Person", "name": "Sunil Sarilla", "url": "https://trailblazers.salesforce.com/profileView?u=0053000000AJ82FAAT", "affiliation": { "@type": "Organization", "name": "M&G Investments" } } } ] } }
Skip to main content
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_Method{get;set;}

 

    public Actionfunction(ApexPages.StandardController controller) {

 

    }

 

    public string ActionFunMethod(){

 

     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>
1 answer
0/9000