function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pradeep RajuPradeep Raju 

Dynamic Visualforce Component for Question & Answer on VF page??

Hi All,

I have a requirement to populate questions with radio buttons Yes or No & capture anwers to those values in the controller by iterating over list.Can anyone please provide info on how to do it ??

Regards,
Pradep.
Sfdc CloudSfdc Cloud
<apex:page standardController="question__c" extensions="GetQuestionList" >

<apex:form >
  <apex:repeat value="{!que}" var="a">
  <apex:pageBlock >
  <apex:pageBlockSection columns="1">
  {!a.Quiz_question__c} {!a.id} <br/>

     <apex:selectRadio value="{!a.Question__r.Answer__c}">
  <apex:selectOption itemValue="{!opt3}" itemLabel="{!a.option_3__c}"/>
  <apex:selectOption itemValue="{!opt4}" itemLabel="{!a.option_4__c}"/>
</apex:selectRadio>  

</apex:pageBlockSection>  
</apex:pageBlock>  
</apex:repeat>
</apex:form>
</apex:page>

Controller
public class GetQuestionList {
question__c q1;
public List<question__c> que{set;}
public List<question__c> getque(){
List<question__C> que= new List<question__c>();
for(question__C q:[select Quiz_question__c,id from question__c]){
    que.add(q);
  system.debug(que);
}
system.debug(que);
return que;
}

public String selectedAns{get;set;} 
public String opt4{get;set;}
public String opt3{get;set;}

public GetQuestionList(ApexPages.StandardController controller) {

}

Refer below link for more clarification
http://stackoverflow.com/questions/20916407/radio-button-value-not-visible-in-vfpage

Hope this helps :)
Pradeep RajuPradeep Raju
Hi Sfdc Cloud,

Do you have any examples that leverage Dynamic Visualforce Component to acheive this kind of requirement ?

Regards,
Pradeep.