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
golugolu 

selectoption values in visualforce page

Hi,
I am trying to pass the values from apex controller to visualforce page for radio buttons. Then i want to pass back the selected value in the controller. can anybody please help. The code written so far 
Visualforce page 



 <apex:repeat value="{!optionsListvf}" var="s">
                <apex:selectRadio >
                    <apex:selectOption > {!s} </apex:selectOption>
                </apex:selectRadio>
            </apex:repeat>




Apex class 

 public List<string> optionsListvf {get;set;}
    
    Public static String buttonbehaviourvf{get;set;}
    
    public  QuestionAnswerController(){
        String question =apexpages.currentpage().getparameters().get('question');
        String optionsList=apexpages.currentpage().getparameters().get('optionsList');
        String buttonbehaviour = apexpages.currentpage().getparameters().get('buttonbehaviour');
        questionvf=question;
        String finalOptions =  optionsList.replace('(','').replace(')','');
        optionsListvf=finalOptions.split(',');
        buttonbehaviourvf=buttonbehaviour;
        
    }

 
Shaik Naga janiShaik Naga jani
HI golu,
Updated the vf page code and apex class
Visualforce page
<apex:repeat value="{!optionsListvf}" var="s">
	<apex:selectRadio value="{!selectedValue}">
		<apex:selectOption > {!s} </apex:selectOption>
	</apex:selectRadio>
</apex:repeat>
Apex Class
public List<string> optionsListvf {get;set;}

public String selectedValue {get;set;}
Public static String buttonbehaviourvf{get;set;}

public  QuestionAnswerController(){
	System.debug('selectedValue =====> '+selectedValue);
	String question =apexpages.currentpage().getparameters().get('question');
	String optionsList=apexpages.currentpage().getparameters().get('optionsList');
	String buttonbehaviour = apexpages.currentpage().getparameters().get('buttonbehaviour');
	questionvf=question;
	String finalOptions =  optionsList.replace('(','').replace(')','');
	optionsListvf=finalOptions.split(',');
	buttonbehaviourvf=buttonbehaviour;
	
}

Kindly mark this as solved if the reply was helpful.
Thanks
Shaik