I have a custom object with 5 Questions and field Api Names are Q1__c, Q2__c, Q3__c, Q4__c, Q5__c

Requirement :

This is a Question answer from with question having more than 40 characters so i am doing in the visualforce page


<apex:page standardcontroller="Phone_Screen__c" extensions="PhoneScreenController">
        <apex:actionFunction name="sendvalues" action="{!process}" reRender="renderme">
            <apex:param assignTo="{!option}" name="value1" value="" />

                <apex:inputField value="{!Phone_Screen__c.Type__c}" styleClass="type" onchange="callmethod()" /> 
                <!--This is a custom picklist field-->

        <apex:pageBlock id="renderme">
            <apex:pageBlockSection rendered="{!panel1}"> 
                <apex:variable var="count" value="{!0}"/>
                <apex:repeat value="{!questions}" var="i">
                    <span id="question{!count}">{!questions[count].Question__c}</span>
                    <textarea id="answer{!count}"></textarea>
                    <apex:variable var="count" value="{!count + 1}"/>


    <script type="text/javascript">
        function callmethod(){



public class PhoneScreenController {

    public Boolean panel1{get; set;}
    public String option{get;set;}

    public PhoneScreenController(ApexPages.StandardController controller) {
        panel1 = false;

    public pageReference process(){
        if(option == 'Value1') {
            panel1 = true; 
        return null;

    public List<Questions__c> getquestions(){
        List<Questions__c> mc = Questions__c.getAll().values();
        return mc;


Issue: I am trying to get the answer for a particular question in textarea and I am looking to save this value to the corresponding question while creating the record. How can I map this value to that question while creating the record as questions come from custom settings and the number of questions can keep changing.

Right now I created a custom setting which has the following fields: - apiname__c : to store the field apiname - question__c: for the question

1 Answer 1


You can create a wrapper class to hold questions and answers and in this getquestions() method return the List of Wrapper class object. It will help you to manipulate and save the data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.