In my Visualforce page I have 3 radio buttons and 2 text fields. If I select the first radio button automatically field 1 is shown and field 2 is hidden.

I select radio button 1 & field 1 and save into the database. When I edit the previously saved data, radio button 1 is not selected. How can I make it selected in edit mode? In edit mode only field value is populating the radio button is not populating below image show it

Radio Button

 <apex:form >
<apex:pageBlock >
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

function show(t)
if ( t == 0 ){

   <apex:pageBlockButtons >
          <apex:commandButton value="Save" action="{!save}"/>
          <apex:commandButton value="Cancel" action="{!cancel}"/>
<apex:pageBlockSection columns="1" title="Shipping Information">
 <apex:selectRadio value="{!Opp__c.shipping_type__c}" onChange="show(this.value);">
 <apex:selectOption itemLabel="Use Store Settings" itemValue="0" />
 <apex:selectOption itemLabel="Per Item" itemValue="1" />
  <apex:selectOption itemLabel="Fixed Price Per Order" itemValue="2"/>
  <apex:inputField value="{!Opp__c.storeprice__c}" id="defaultcost" style="display:block;"/>
   <apex:inputField value="{!Opp__c.price__c}" id="differcost" style="display:none;"/>


  • Can you specify the issue more clearly may be with the code as well? – highfive Apr 17 '14 at 7:02
  • @highfive Can you check it i modify my code. – Sathya Apr 17 '14 at 7:06
  • The page you have posted looks OK to me. So the problem may be in your save method. I suggest you add a System.debug to that to check the value of Opp__c.shipping_type__c as the save happens, and if that is OK use the Developer Console to query the object after the save to make sure the field value was persisted. You probably haven't got to it yet, but you presumably will need to add jQuery to correctly set the display status of the 2 fields when the page loads. – Keith C Apr 17 '14 at 7:56
  • @KeithC the save method is working fine when i click run the query means it showing the values which are store in the Shipping_type__c. Actually i overwite the standard edit button with my vf page, in this case it is no showing. – Sathya Apr 17 '14 at 8:03
  • @Sathya Would be worth adding <apex:outputText value="{!Opp__c.shipping_type__c}"/> to the page to see the raw value. But I'm out of ideas as to the cause... – Keith C Apr 17 '14 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.