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
Ker DeveloperKer Developer 

Radio button to select records and check one by default

Hello Every body ,


I need to use radio buttons to select Salesforce records (not simple values). I used the input radio but the problem is that i can't make one of these checked by default based on a value returned from the controller . 


Here is the code of the Visualforce : 


<apex:pageblock id="consel" title="Couleurs">
            <apex:pageblocktable id="allcons" value="{!SelectedCouleur}" var="selcolor">  
            <apex:column headervalue="Sélectionner">
                           <apex:actionsupport action="{!selectcouleur}" event="onclick" rerender="label">  
                        <input type="radio" name="couleur"/>                    
                            <apex:param name="couleurid " value="{!selcolor.Id}" assignTo="{!idcouleur}">
                    <apex:column headervalue="Couleur extérieur">
                        <apex:outputfield value="{!selcolor.Couleurexterieur__r.Name}">
                    <apex:column headervalue="Garniture">
                        <apex:outputfield value="{!selcolor.Couleurinterieur__r.Name}">
                    <apex:column headervalue="Prix couleur extérieur">
                        <apex:outputfield value="{!selcolor.Prixexterieur__c}">
                    <apex:column headervalue="Prix Garniture">
                        <apex:outputfield value="{!selcolor.Prixcouleurinterieur__c}">

 Thank you for your advance Help !






I had the same problem, I've used smth like below and it worked:


<apex:column rendered="{!IF(item.offered == selProd,'true','false')}">
<input type="radio" name="group1" onclick="methodOneInJavascript('{!item.offered}')" checked="true"/>

<apex:column rendered="{!IF(item.offered == selProd,'false','true')}">
<input type="radio" name="group1" onclick="methodOneInJavascript('{!item.offered}')"/>


I hope it will also help You.



Best regards!

Ker DeveloperKer Developer

Hello , 


Could you please provide me with the code of the javascript method?




<apex:actionFunction action="{!methodOne}" name="methodOneInJavascript" rerender="buttonSec">
<apex:param name="firstParam" assignTo="{!selProd}" value="" />


{!methodOne} is not relevant here, I've used it to additionaly process some additional piece of data.