I have converted two picklists into radio buttons. I want to select only one radio button from two radio button groups. I also write jquery for this two group but it's not working. please help me out.
//----------apex code--------------
public List<SelectOption> getTemplate(){
List<SelectOption> options = new List<SelectOption>();
Schema.sObjectType sObject_Type = Proposal_Version__c.getSObjectType();
Schema.DescribeSObjectResult sObject_Result = sObject_Type.getDescribe();
Map<String,Schema.SObjectField> fieldMap = sObject_Result.fields.getMap();
List<Schema.PicklistEntry> picklist_values = fieldMap.get('Template__c').getDescribe().getPickListValues();
for (Schema.PicklistEntry a : picklist_values) {
options.add(new selectOption(a.getLabel(),a.getValue()));
}
return options;
}
public List<SelectOption> getTemplateBundeles(){
List<SelectOption> options = new List<SelectOption>();
Schema.sObjectType sObject_Type = Proposal_Version__c.getSObjectType();
Schema.DescribeSObjectResult sObject_Result = sObject_Type.getDescribe();
Map<String,Schema.SObjectField> fieldMap = sObject_Result.fields.getMap();
List<Schema.PicklistEntry> picklist_values = fieldMap.get('Template_Bundles__c').getDescribe().getPickListValues();
for (Schema.PicklistEntry a : picklist_values) {
options.add(new selectOption(a.getLabel(),a.getValue()));
}
return options;
}
//----- Vf code--------
<apex:pageBlockSection title="Template Hosting Fees" columns="1" >
<apex:pageBlockSectionItem >
<apex:outputLabel >Template</apex:outputLabel>
<apex:selectRadio styleClass="TemplateGroup" id="IdRedioBtnTemplateHostingFee" value="{!ProposalVersion.Template__c}" onchange="test(this);">
<apex:selectOptions value="{!Template}"></apex:selectOptions>
</apex:selectRadio>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >OR</apex:outputLabel>
<apex:outputLabel ></apex:outputLabel>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Multiple Tamplates</apex:outputLabel>
<apex:selectRadio styleClass="TemplateGroup" id="IdRedioBtnHostingBundles" value="{!ProposalVersion.Template_Bundles__c}" onchange="test(this);">
<apex:selectOptions value="{!TemplateBundeles}"></apex:selectOptions>
</apex:selectRadio>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
//------- Jquery-----
function test(sender){
$('.TemplateGroup').find('input:radio').each(function(){
$(this).prop('checked', false);
});
$(sender).prop('checked', true);
}
html
after rendering from browser;