+ Start a Discussion
ArjunmcaArjunmca 

How to pass parameters from VF to controller

Hi,

 

I have VF page which has 4 check boxes, i want to pass the selected  checkbox to controller.

How can i do that?

 

Can any body help me on this.

 

Thanks.

 

SFDC_VikashSFDC_Vikash

Hi 

 

If you are talking about indiviual checkboxes, then define 4 variable in controller class as : 

 

public boolean selectedCheck1 {get;set;}

public boolean selectedCheck2 {get;set;}

public boolean selectedCheck3 {get;set;}

public boolean selectedCheck4 {get;set;}

 

And use on VF page as :

 

<apex:inputCheckbox value="{!selectedCheck1}" />

<apex:inputCheckbox value="{!selectedCheck2}" /> and soon

 

Whenever a checkbox is selected the corresponding variable will be set to true, that you can use in controller class to create the logic.

 

If you let me know the exact scenario then i can help you out more specific.

sandeep@Salesforcesandeep@Salesforce

there are many ways here is one

Apex:ActionFunction 

I ampassing value in field "inputValue" property binded with page.

 

public Clas testing{

String inputValue{get;set;}
public testing()
{
}
public void dummy()
{
system.debug('=======check==='+inputValue);// it should be testData
}
}

<apex:page controller="testing" >
<apex:form id="frmId">
<apex:actionfunction name="passvalue" action="" >
<apex:param name="param1" value="" assignTo="{!inputValue}"/>
</apex:actionfunction>
<apex:commandbutton Action="{!dummy}" onclick="passvalue('testData')" reRender="frmId" value="submit" />
</apex:form>

</apex:page>