• Pradeep Pss
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
In my scenario i have a list of questions i need to capture the selected options to an object on submiting the questionaire. SelectRadio is placed inside a repeat to load questions from a master object. 

I need to get the question id and selected value of the questions and save it to an object.

VF Page
 <apex:repeat value="{!QuesList}" var="a">
     
      <apex:pageBlockSection columns="1" >
                 <apex:pageBlockSectionItem ><B>{!a.MSWq1__c}</B>
                      </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                 <apex:selectRadio layout="pageDirection" styleClass="test">
                    <apex:selectOption itemLabel="{!a.Option1__c}" itemValue="A"></apex:selectOption>
                    <apex:selectOption itemLabel="{!a.option2__c}" itemvalue="B"></apex:selectOption>
                    <apex:selectOption itemlabel="{!a.option3__c}" itemvalue="C"></apex:selectOption>
                     <apex:selectOption itemlabel="{!a.option4__c}" itemvalue="D"></apex:selectOption>
                    </apex:selectRadio> 
                 </apex:pageBlockSectionItem>
                  </apex:pageBlockSection> 
     </apex:repeat>
    </apex:pageBlock>
Controller 
 
public class ctrlQuestions {

public Assessment__c main{get; set;}
public List<master__c> QuesList {get; set;}

public ctrlQuestions(){
main=newAssessment__c();
QuesList = new List<master__c>();
QuesList = [select Name,MSWq1__c,Option1__c,Option2__c,Option3__c,Option4__c,Correct_Option_Choice__c from MSW_master__c where Isactive__c= true];
}
public PageReference saveandred() {
   insert main; 
        
        return new PageReference('/Test/'+main.Id);
    }
}