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
nagasnagas 

radio button issue.

hi i wrote visualforce page in which the user enters search criteria and enters a list of records comes up with radio buttons where the user should select one and click on submitt and some operation will be done. everything is going good but when i display those records the user is able to select mutiple radio buttons how can i restrict so that the user can only select one radio button.

SSRS2SSRS2

I think your scenario as  follow and see following sample taken from selectRadio component.

 

<!-- Page: -->
<apex:page controller="sampleCon">
    <apex:form>
        <apex:selectRadio value="{!country}">
            <apex:selectOptions value="{!items}"/>
            </apex:selectRadio><p/>
            <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
     </apex:form>
     <apex:outputPanel id="out">
          <apex:actionstatus id="status" startText="testing..."> 
             <apex:facet name="stop"> 
               <apex:outputPanel> 
                  <p>You have selected:</p> 
                 <apex:outputText value="{!country}"/> 
              </apex:outputPanel> 
            </apex:facet> 
          </apex:actionstatus> 
     </apex:outputPanel> 
</apex:page>
            
/*** Controller ***/
public class sampleCon {
    String country = null;
         
    public PageReference test() {
        return null;
    }
                
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('US','US')); 
        options.add(new SelectOption('CANADA','Canada')); 
        options.add(new SelectOption('MEXICO','Mexico')); return options; 
    }
                   
    public String getCountry() {
        return country;
    }
                    
    public void setCountry(String country) { this.country = country; }
}

 

 

-Suresh

Pradeep_NavatarPradeep_Navatar

You can create radio button group through JQuery Concept. Find below a sample code for checkbox grouping :

 

            <script>

                   $(document).ready(function()

                   {

                   $('input[title=Checkbox1]').click(function(event,ui){   

                   $('input[title=Checkbox1]').checkBox('changeCheckStatus', false)

                   $(this).checkBox('changeCheckStatus', true)

                    });

                    });

            <script>                   

            <apex:inputCheckbox value="{!tdisabled}" styleclass="form-checkbox" title="Checkbox1"/>Yes

            <apex:inputCheckbox value="{!tenabled}" styleclass="form-checkbox" title="Checkbox1"/>No

 

Hope this helps.