You need to sign in to do that
Don't have an account?
Hardik Chavda
How can I use <apex:param> value as a parameter in javascript function?
Following is my code.
<apex:actionFunction action="{!BusinessPartnering}" name="BusinessPartnering" oncomplete="onPageRerender();endProcess();ChangeBackgroundColor(//pass the value of <apex:param>');" reRender="AssessmentBody">
<apex:param name="firstParam" assignTo="{!FunctionalAreaParam}" value="" />
</apex:actionFunction>
Now here, I want to pass the <apex:param> value as a argument in ChangeBackgroundcolor() method. Can anyone help me with this?
<apex:actionFunction action="{!BusinessPartnering}" name="BusinessPartnering" oncomplete="onPageRerender();endProcess();ChangeBackgroundColor(//pass the value of <apex:param>');" reRender="AssessmentBody">
<apex:param name="firstParam" assignTo="{!FunctionalAreaParam}" value="" />
</apex:actionFunction>
Now here, I want to pass the <apex:param> value as a argument in ChangeBackgroundcolor() method. Can anyone help me with this?
I think you can directly bind the function ChangeBackgroundcolor to your actual param.
Try writing something like this :
Regards,
Alexandre
All Answers
Example 1:-
Example 2:- Please check below blog
http://www.cloudforce4u.com/2013/09/passing-parameters-in-action-function.html
Example 3:-
http://www.salesforceworld.blogspot.in/2011/06/parameter-passing-using.html#!http://salesforceworld.blogspot.com/2011/06/parameter-passing-using.html
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');
Please let us know if above solution will help u.
Thanks
Amit Chaudhary
I think you can directly bind the function ChangeBackgroundcolor to your actual param.
Try writing something like this :
Regards,
Alexandre
Thanks for the reply, But I think you don't get my question here. I know how to use apex:param but What I wanted is that how to use apex:param value in javascript function as a parameter? and the value which will be passed in param shall be used in javascript function parameter dynamically.