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
sweety kuttisweety kutti 

I want to select radio button inside apex:repeat by using input not using apex:selectRadio tag.

I want to select radio button inside apex:repeat by using input not using apex:selectRadio tag...Can anyone suggest...Here is my code..
I am not able to display the  table with corresponding radio button record values on click of radio button...Please help me...Its an urgent task

<apex:outputPanel id="pnl" rendered="{!showResult}">
                                <br/>
                                <div class="slds-p-horizontal--medium" >
                                    <div style="color:white; background-color:#B0C4DE; height:30px; border-width:2px 0 0; border-style:solid; border-color:#00008B" class="slds-p-left--medium">
                                    <h2 class="slds-text-title slds-p-top--xx-small"><strong>Injured Worker-Search Results</strong></h2>
                                    </div></div>

                                <div class="slds-p-around--medium">
                                <div class="slds-card">
                                    <div class="slds-card__body">
                                        <table id="Search Results" class="slds-table slds-table--bordered slds-table--cell-buffer">
                                            <thead  style="width:100%">
                                                <tr>
                                                    <th  scope="col"><b>Select</b></th>
                                                    <th  scope="col"><center><b>First Name</b></center></th>
                                                    <th  scope="col"><center><b>Last Name</b></center></th>
                                                    <th  style="font-size:14px;color:#000000;" scope="col"><center><b>Birth Date</b></center></th>
                                                </tr>
                                            </thead>
                                            <tbody > 
                                                            <!-- READ OUT DATA -->
                                                <apex:repeat value="{!accountList}"  var="acclist">
                                                    <tr > 
                                                        <td scope="row" data-label="Select">
                                                               
                                                                    <input type="radio" name="<strong>selectRadio</strong>" id= "radio" onclick="radioSearch()" reRender="frm1" status="actStatus" ></input>
                                                                       <apex:param value="{!acclist.id}" name="ID"  />
                                                                   
                                                               <!-- <apex:selectRadio> 
                                                                    <apex:selectOptions value="{!ID}" >
                                                                    </apex:selectOptions>
                                                                    <apex:actionSupport event="onClick" action="{!selectedPerson}" ></apex:actionSupport>
                                                                </apex:selectRadio>   -->                                               
                                                        </td>
                                                        <td scope="row"  data-label="First Name"><center>{!acclist.FirstName}</center></td>
                                                        <td scope="row"  data-label="Last Name"><center>{!acclist.LastName}</center></td>
                                                        <td scope="row"  data-label="Birth Date"><center>{!acclist.PersonBirthdate}</center></td>
                                                    </tr>
                                                </apex:repeat>
                                                  
                                         </tbody>
                                        </table>
                                    </div>
                                </div>
                                </div>
                                        
                            </apex:outputPanel>
                           
                                        <apex:actionFunction name="selectionRadio" action="{!selectedPerson}" reRender="frm1,pnl" status="actStatus">
                                         
                                              
                                               </apex:actionFunction> 
Pankaj MehraPankaj Mehra
Hi Sweety,

You can create a JS method that capture onclick event on radio buttons in loop and populate a hidden textbox with selected ID.
<apex:pageBlockTable value="{!someList}" var="con">
<apex:column value="{!con.name}" />

<apex:column>
    <input type="radio" name="chosen" id="{!con.id}" VALUE="{!con.id}" onclick="changeValue(this,'{!$Component.RadioButtonValue}');"/>
</apex:column>    

</apex:pageBlockTable>

<apex:inputHidden value="{!contactId}" id="RadioButtonValue" />



<script>
function changeValue(input, textid) {
    document.getElementById(textid).value = input.value;
}   
</script>


If you're satisfied with the answers provided, please don't forget to select a Best Answer.
Thanks!
sweety kuttisweety kutti
I am not interested in pageBlockTable..Can anybody help me
Pankaj MehraPankaj Mehra
Hi Sweety,

You can take example of my code and convert it to table instead of pageblocksection :
 
<apex:outputPanel id="pnl" rendered="{!showResult}">
                                <br/>
                                <div class="slds-p-horizontal--medium" >
                                    <div style="color:white; background-color:#B0C4DE; height:30px; border-width:2px 0 0; border-style:solid; border-color:#00008B" class="slds-p-left--medium">
                                    <h2 class="slds-text-title slds-p-top--xx-small"><strong>Injured Worker-Search Results</strong></h2>
                                    </div></div>

                                <div class="slds-p-around--medium">
                                <div class="slds-card">
                                    <div class="slds-card__body">
                                        <table id="Search Results" class="slds-table slds-table--bordered slds-table--cell-buffer">
                                            <thead  style="width:100%">
                                                <tr>
                                                    <th  scope="col"><b>Select</b></th>
                                                    <th  scope="col"><center><b>First Name</b></center></th>
                                                    <th  scope="col"><center><b>Last Name</b></center></th>
                                                    <th  style="font-size:14px;color:#000000;" scope="col"><center><b>Birth Date</b></center></th>
                                                </tr>
                                            </thead>
                                            <tbody > 
                                                            <!-- READ OUT DATA -->
                                                <apex:repeat value="{!accountList}"  var="acclist">
                                                    <tr > 
                                                        <td scope="row" data-label="Select">
                                                               
                                                                    
<input type="radio" name="chosen" id="{!acclist.id}" VALUE="{!acclist.id}" onclick="changeValue(this,'{!$Component.RadioButtonValue}');"/>
                                                                       <apex:param value="{!acclist.id}" name="ID"  />
                                                                   
                                                               <!-- <apex:selectRadio> 
                                                                    <apex:selectOptions value="{!ID}" >
                                                                    </apex:selectOptions>
                                                                    <apex:actionSupport event="onClick" action="{!selectedPerson}" ></apex:actionSupport>
                                                                </apex:selectRadio>   -->                                               
                                                        </td>
                                                        <td scope="row"  data-label="First Name"><center>{!acclist.FirstName}</center></td>
                                                        <td scope="row"  data-label="Last Name"><center>{!acclist.LastName}</center></td>
                                                        <td scope="row"  data-label="Birth Date"><center>{!acclist.PersonBirthdate}</center></td>
                                                    </tr>
                                                </apex:repeat>
                                                  
                                         </tbody>
                                        </table>
                                    </div>
                                </div>
                                </div>
                                        
                            </apex:outputPanel>
                           

<apex:inputHidden value="{!accountId}" id="RadioButtonValue" /> 
<script> function changeValue(input, textid) { document.getElementById(textid).value = input.value; } </script>
                                        <apex:actionFunction name="selectionRadio" action="{!selectedPerson}" reRender="frm1,pnl" status="actStatus">
                                         
                                              
                                               </apex:actionFunction>

You can get the value of selected account in variable accountId in controller function selectedPerson [Create accountId variable in controller ]

Thanks
sweety kuttisweety kutti
Its not working for me...Even its not taking the value to controller..i.e accountId value