• Kwei Chan
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi,

For some odd reason, I'm unable to pass the parameter using APEX:ACTIONFUNCTION.

 

Code Snippet:

 

VF PAGE:

<apex:page standardController="Service_Catalogue__c" extensions="serviceCatalogueCtrl">

<script>
function fnChange(a)
{
alert('Hello Param'+a);
testJs(a);
alert(a);
}

<apex:form>

<apex:actionFunction name="testJs" action="{!testJs}" rerender="" >
<apex:param value="" id="y" assignTo="{!subCategory}" />
</apex:actionFunction>

 

<apex:inputField value="{!Service_Catalogue__c.Category__c}"/>
<apex:inputField value="{!Service_Catalogue__c.SubCategory__c}" onchange="fnChange(this.value);" />

</apex:form>

</apex:page>

 

APEX CLASS:

public class serviceCatalogueCtrl {

 public string subCategory{get;set;}

public serviceCatalogueCtrl(ApexPages.StandardController controller) {
}

public PageReference testJs()
{
system.debug('Hello subCategory @@'+subCategory);

return null;
}

}

 

 

Service catalogue is my custom object which has 2 picklist fields category and subcategory.

I want to pass the value that I selected in subcategory field and pass it to my controller for further processing.

 

But for some reason subcategory value is not getting set while trying to set in actionfunction.

 

It looks simple but I'm missing something.

Many thanks in advance for your help:)

Thank You!