Parameter passing using Javascript+actionFunction in visualforce

In visualforce, there is a method for passing parameters from visualforce page to controller using javascript and actionFunction. Here is the example;

/*JavaScript*/
<script type="text/javascript">
function doSave(date) {
paraFunction(document.getElementById(date).value);
}
</script>

/*Action Function*/
<apex:actionFunction name="paraFunction" action="{!saveInterviewDate}" rerender="view">     
<apex:param id="aname" name="interviewDate" value="" />
</apex:actionFunction>

/*Call the javaScript from here*/
<apex:commandLink onclick="doSave('{!$Component.interviewDate}');">               
<apex:commandButton value="Save"/>
</apex:commandLink>

/*get the parameter in controller*/
String interviewdate=Apexpages.currentPage().getParameters().get('interviewDate');

Comments

  1. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.
    Vee Eee Technologies

    ReplyDelete
  2. Very helpful link.. Thank you for sharing it!

    ReplyDelete
  3. Nice post...I look forward to reading more, and getting a more active part in the talks here, whilst picking up some knowledge as well..

    Pass Box manufacturers

    ReplyDelete

Post a Comment

Popular posts from this blog

Where’s Astro, the missing Trailhead mascot?