+ Start a Discussion
Anirudh Sharma 5Anirudh Sharma 5 

I have a VF page

I have a VF page and I have a multi check box field in that so when a person selects certain options in that question dynamicaly another field should populate when he selects certain options. so how can I do that.

Hi Anirudh,

The following VF page has 4 checkboxes and a textbox. The textbox is populated with the value of the checkbox that is selected.

You can use the code and modify it as per your requirement.

VF Page :
<apex:page controller="ChkboxController">
    <apex:form >
      <apex:selectCheckboxes value="{!certVals}">
          <apex:selectOptions value="{!items}"></apex:selectOptions>
          <apex:actionSupport reRender="valcert" event="onchange" action="{!printValue}"/>          
     <apex:outputPanel id="valcert">
         <apex:inputText value="{!certValue }"></apex:inputText>          
Controller :
public with sharing class ChkboxController

    public String certValue { get; set; }
    String[] certVals = new String[]{};
    public ChkboxController()
    public List<SelectOption> getItems() 
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('Salesforce Admin','Salesforce Admin'));
        options.add(new SelectOption('Salesforce Advance Admin','Salesforce Advance Admin'));
        options.add(new SelectOption('Salesforce Developer','Salesforce Developer'));
        options.add(new SelectOption('Other','Other'));
        return options;
    public String[] getcertVals() 
        return certVals; 
    public void setcertVals(String[] certVals)
        this.certVals = certVals;
    public pageReference printValue()
            certValue = certVals[0];           
            certValue = '';
        return null;
Use it only as a template and do all the necessary checks and modification as per your requirement.


PS: If this resolved your issue kindly mark it as the solution.