You need to sign in to do that
Don't have an account?

Why actionFuntion can't send parameter?
Visual Page:
Controller:
Log debug:
Why actionFuntion can't send parameter?
<li><a href="" onclick="getProduct('{!fa.Family}'); return false;">{!fa.Family}</a></li> <apex:actionFunction action="{!searchByFamily}" name="getProductFamily" > <apex:param name="family" value="" assignTo="{!family}" /> </apex:actionFunction> <script> function getProduct(family) { getProductFamily(family); } </script>
Controller:
public string family { get;set;} public void searchByFamily(){ System.debug(family); string searchquery='select ProductCode,Name,ImageName__c,(Select UnitPrice,Pricebook2.Name From PricebookEntries where IsActive=True) from Product2 where Family=:family '; MyProducts= Database.query(searchquery); }
Log debug:
04:27:26.0 (32330563)|USER_DEBUG|[98]|DEBUG|null
Why actionFuntion can't send parameter?
Yes, You can use apex:actionFunction.
In visualforce, there is a method for passing parameters from visualforce page to controller using javascript and actionFunction. Here is the example;
Refer this URL: http://www.jitendrazaa.com/blog/salesforce/passing-parameter-in-actionfunction-in-visualforce/
Thank You
Mohd Rais
All Answers
Visualforce page code:
Controller code:
Please understand this.
you need write the value of your list var {value="{!fa.id}"}.
<apex:actionSupport event="onclick" action="{!searchByFamily}" ReRender="conpgblk">
<apex:param assignTo="{!family}" name="familyname" value="{!fa.id}"/>//var of your list(searchquery)ex-fa;
</apex:actionSupport>
Please let me know if you have any query.
Please mark it as best Answer if you find it helpful.
Thank You
Ajay Dubedi
Yes, You can use apex:actionFunction.
In visualforce, there is a method for passing parameters from visualforce page to controller using javascript and actionFunction. Here is the example;
Refer this URL: http://www.jitendrazaa.com/blog/salesforce/passing-parameter-in-actionfunction-in-visualforce/
Thank You
Mohd Rais