You need to sign in to do that
Don't have an account?
madhan bondalapati
Selecting a radio button one at a time
Hi All i want to select a radio one at time ,but in my case i am selecting all radio buttons.Could you please help me in this issue.
I want to the save the selected values in the custom object .Here is my code for Visual force page and controller
Visualforce page :
<apex:page showHeader="false" sidebar="false" controller="SurveyContact">
<apex:pageMessages />
<div align="center">
<h1> Survey For Contact </h1>
</div>
<apex:form >
<apex:pageBlock title="Survey Questions">
<apex:outputPanel rendered="{!FirstScreen}">
<apex:actionRegion >
You will be answering a bunch of questions to plan your Long weekend in a Relaxing way. <br/>
Click Start button below to get to your first question. <br/><br/>
<apex:commandButton value="Start" action="{!StartSurvey}"/>
</apex:actionRegion>
</apex:outputPanel>
<apex:outputPanel rendered="{!FirstQuestion}">
<apex:actionRegion >
<table>
<tr>
<td>
<apex:outputLabel value="Fun places to visit "/>
</td>
<td>
<apex:selectRadio value="{!PlaceToVisit}"/>
</td>
<td>
Grand prismatic spring
</td>
<td>
<apex:selectRadio value="{!PlaceToVisit}"/>
</td>
<td>
Grand Canyon of Yellowstone
</td>
<td>
<apex:selectRadio value="{!PlaceToVisit}"/>
</td>
<td>
Hayden Valley
</td>
<td>
<apex:selectradio value="{!PlaceToVisit}"/>
</td>
<td>
Mammoth Springs
</td>
<td>
<apex:selectradio value="{!PlaceToVisit}"/>
</td>
<td>
Norris Geyser Basin
</td>
</tr>
</table>
<apex:commandButton value="Next" action="{!next}"/>
</apex:actionRegion>
</apex:outputPanel>
</apex:pageBlock>
<!--<div align="center" draggable="false" >
<apex:commandButton action="{!save}" value="Save"/>
<apex:commandButton value="Next"/>
</div>-->
</apex:form>
</apex:page>
Controller:
public with sharing class SurveyContact {
public String SurveySatisfaction {get;set;}
public String PlaceToVisit {get;set;}
public boolean FirstQuestion {get;set;}
public boolean SecondQuestion {get;set;}
public boolean FirstScreen {get;set;} {FirstScreen = true;}
public PageReference save(){
PageReference pr =new PageReference('a0W/e');
return pr;
}
public void StartSurvey(){
FirstQuestion = true;
FirstScreen = false;
}
public void next() {
FirstQuestion=False;
SecondQuestion=True;
}
}
I want to the save the selected values in the custom object .Here is my code for Visual force page and controller
Visualforce page :
<apex:page showHeader="false" sidebar="false" controller="SurveyContact">
<apex:pageMessages />
<div align="center">
<h1> Survey For Contact </h1>
</div>
<apex:form >
<apex:pageBlock title="Survey Questions">
<apex:outputPanel rendered="{!FirstScreen}">
<apex:actionRegion >
You will be answering a bunch of questions to plan your Long weekend in a Relaxing way. <br/>
Click Start button below to get to your first question. <br/><br/>
<apex:commandButton value="Start" action="{!StartSurvey}"/>
</apex:actionRegion>
</apex:outputPanel>
<apex:outputPanel rendered="{!FirstQuestion}">
<apex:actionRegion >
<table>
<tr>
<td>
<apex:outputLabel value="Fun places to visit "/>
</td>
<td>
<apex:selectRadio value="{!PlaceToVisit}"/>
</td>
<td>
Grand prismatic spring
</td>
<td>
<apex:selectRadio value="{!PlaceToVisit}"/>
</td>
<td>
Grand Canyon of Yellowstone
</td>
<td>
<apex:selectRadio value="{!PlaceToVisit}"/>
</td>
<td>
Hayden Valley
</td>
<td>
<apex:selectradio value="{!PlaceToVisit}"/>
</td>
<td>
Mammoth Springs
</td>
<td>
<apex:selectradio value="{!PlaceToVisit}"/>
</td>
<td>
Norris Geyser Basin
</td>
</tr>
</table>
<apex:commandButton value="Next" action="{!next}"/>
</apex:actionRegion>
</apex:outputPanel>
</apex:pageBlock>
<!--<div align="center" draggable="false" >
<apex:commandButton action="{!save}" value="Save"/>
<apex:commandButton value="Next"/>
</div>-->
</apex:form>
</apex:page>
Controller:
public with sharing class SurveyContact {
public String SurveySatisfaction {get;set;}
public String PlaceToVisit {get;set;}
public boolean FirstQuestion {get;set;}
public boolean SecondQuestion {get;set;}
public boolean FirstScreen {get;set;} {FirstScreen = true;}
public PageReference save(){
PageReference pr =new PageReference('a0W/e');
return pr;
}
public void StartSurvey(){
FirstQuestion = true;
FirstScreen = false;
}
public void next() {
FirstQuestion=False;
SecondQuestion=True;
}
}
Change your VFP Code to
It should work for you.
Thanks
Shashikant