• Roopali Agarwal
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hello,

I have a VF page at the Account level.  The page includes 3 radio buttons.  I am trying to populate 1 of 3 checkbox fields on the Account depending upon the value the user selects in the radio buttons.  I have my page set up to render sections basd upon the radio button selected, and that works great.  However, I cannot figure out how to populate the appropriate checkbox field when the specific radio button is selected.  Can anyone help?
 
<apex:page standardController="Account" tabStyle="Account" id="thePage">

<script>
    function TypeSelect(variable)
    {
        var choice = variable.value;
        if(choice == 'Amp'){
            document.getElementById('layoutAmp').style.display = 'block';
            document.getElementById('layoutEng').style.display = 'none';
            document.getElementById('layoutAge').style.display = 'none';
            document.getElementById('{!$Component.thePage.theForm.AmpVal}').value = true;
        }
        else if(choice == 'Eng'){
            document.getElementById('layoutAmp').style.display = 'none';
            document.getElementById('layoutEng').style.display = 'block';
            document.getElementById('layoutAge').style.display = 'none';
            document.getElementById('{!$Component.thePage.theForm.EngVal}').value = true;
        }
        else{
            document.getElementById('layoutAmp').style.display = 'none';
            document.getElementById('layoutEng').style.display = 'block';
            document.getElementById('{!$Component.thePage.theForm.geVal}').value = true';
        }
    }   
</script>

<style>
    input[type=radio] {margin-left: 100px;}
    .radioClass {margin-left: 25%;}
</style>


<apex:form id="theForm">
    <apex:actionRegion >
        <div class="sectBody">
            <Table width="90%" border="0" cellpadding="0" cellspacing="0" columns="5">
                 <tr>
                     <td colspan="5" class="fieldLabel">
                     <apex:selectRadio layout="lineDirection" styleClass="radioClass" onclick="TypeSelect(this);">
                      <apex:selectOption itemLabel="Amp" itemValue="Amp"></apex:selectOption>
                            <apex:selectOption itemLabel="Eng" itemValue="Eng"></apex:selectOption>
                            <apex:selectOption itemLabel="Age" itemValue="Age"></apex:selectOption>
                     </apex:selectRadio>
                     <apex:actionSupport event="onchange" reRender="checkBox"/>
               </td>
          </tr>\    
     </Table><br/><br/>
        </div>


	<div id="checkBox">
    	<apex:inputField id="AmpVal" value="{!Account.Amp_Account__c}" />
    	<apex:inputField id="EngVal" value="{!Account.Eng_Account__c}" />
        <apex:inputField id="AgeVal" value="{!Account.Age_Account__c}" />
    </div>