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
mac_046mac_046 

Problem with radio button

Hi All,

 

I am using Checkbox in Page Block table. I am getting data from external system by invoking a webservice and displaying it in Page Block Table. I need to replce the Checkbox with Radio Button, But when I use the  Radio Button<selectRadio> tag it is getting selected by default for all the records can anyone help me out from this issue....

 

<apex:page StandardController="Opportunity" extensions="Sync_Page" >
   
       <script type="text/javascript">
        var selectedCheckBox;
        function deSelectOthers(CheckBox){
            if(CheckBox.checked){
                if((CheckBox != selectedCheckBox) && (selectedCheckBox != null))
                    selectedCheckBox.checked = false;
                }
             selectedCheckBox = CheckBox;
        }
         </script> 

    <b><apex:sectionHeader description="Deal Review Details" title="Opportunity"/></b>
        <apex:form id="formId">
          <apex:pageBlock id="pgbId">
            <apex:pageBlockButtons >
                 <apex:commandButton value="Save" action="{!Submit}"/>                  
                 <apex:commandButton value="Cancel" action="{!redirect1}" />
                 <apex:commandButton value="Get Details" action="{!redirect}"/>            
            </apex:pageblockButtons>
                <apex:pageMessages />
                <apex:pageBlockSection title="Deal Review Details"  columns="1" id="pgbsId">
                    <apex:pageBlockTable value="{!dealsList}" var="db"  id="drDetails">
                        <apex:column headerValue="Select" ><apex:inputCheckbox value="{!db.Checkbox}" onclick="deSelectOthers(this)" /></apex:column>                              
                        <apex:column headerValue="Last Modified Date" value="{!db.Closedate}"/>
                        <apex:column headerValue="Customer Name" value="{!db.CustomerName}"/>
                        <apex:column headerValue="Deal Name" value="{!db.Name}"/>
                        <apex:column headerValue="Deal Review Phase" value="{!db.Phase}"/>
                        <apex:column headerValue="Deal Review Stage" value="{!db.Status}"/>
                       
                    </apex:pageblockTable>
                 </apex:pageBlockSection>
              </apex:pageBlock>
           </apex:form>
</apex:page>

 

Thanks in advance.........

b-Forceb-Force

I think below code snippet will help you

 

Visual Force Page

 

<table class="list" cellspacing="0" cellspading="0" border="0">
<tr class="ui-state-focus"><th>Select One</th><th>Campaign Name </th><th>Start Date</th><th>End Date</th></tr>
<apex:repeat var="cm" Value="{!lstCamp}">
<tr>
<td>
  <input type="radio" name="rdoSelect" checked="{!cm.bcampSelected}" id="{!cm.objCamp.Id}"/> 
</td>
<td>
<apex:outputText Value="{!cm.objCamp.Name}" ></apex:outputText>
</td>
<td>
<apex:outputText Value="{!cm.objCamp.StartDate}" ></apex:outputText>
</td>
<td>
<apex:outputText Value="{!cm.objCamp.EndDate}" ></apex:outputText>
</td>
</tr>
</apex:repeat>
</table>

 Controller

 

public class ComboCampaign
{
public boolean bcampSelected{get;set;}
public Campaign objCamp{get;set;}
}

public List<ComboCampaign> lstCamp{get;set;}

List<Campaign> lc=[Select Id, Name,StartDate,EndDate from Campaign limit 50]; 

lstCamp=new List<ComboCampaign>(); 
for(integer i=0; i < lc.size() ; i++)    
{
ComboCampaign objC=new ComboCampaign();
objC.objCamp=new Campaign(); 
objC.objCamp=lc[i];
lstCamp.add(objC); 
}

Above VF page and Controller shows Campaign with some [Information Name, Start Date , End Date] with Radio Button infront of each row.

 

I had use inner class to create list, you can create list with some simple datastructure.

 

Let me know If you need any more information.

 

 

Thanks,

Bala

 

 

 

mac_046mac_046

hi

Prazzy APrazzy A

Hi, I got the display but how can I retrieve the value in the controller once a value is selected?