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
vfexp31.3955631467313875E12vfexp31.3955631467313875E12 

Radio Button Click is not working

HI,

    I have 3 radio buttons in my visaulforce page, and 2 text fields, when i click 1st radio button at that time 1st text field will be display, when i click 2nd Radio button 2nd Field will be display, when i click 3rd Radio Button again 2nd radio button will be display, i am using javascript for hide/show the text fields but it's not working can any one give me suggestions.

   JavaScript--

  <script type="text/javascript">

  function show(t)
  {
     if ( t.value == 0 )
     {
        document.getElementById("defaultcost").style.display = 'block';
        document.getElementById("differcost").style.display = 'none';
     }else{
         document.getElementById("defaultcost").style.display = 'none';
          document.getElementById("differcost").style.display = 'block';
     }
   
 
  }
 
 
 
  </script>


    <apex:selectRadio value="{!Quote__c.shipping_type__c}" onChange="show(this);">
          
            <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:selectRadio>
           <apex:inputField value="{!Quote__c.storeprice__c}" id="defaultcost" style="display:block;"/><br/>
           <apex:inputField value="{!Quote__c.price__c}" id="differcost" style="display:none;"/><br/>
         
          </apex:pageBlockSection>
NehalNehal (Salesforce Developers) 
Hi,

Please review the links below on how to use javascript or hide/show the text fields:

1.http://stackoverflow.com/questions/17621515/how-to-show-and-hide-input-fields-based-on-radio-button-selection
2.http://stackoverflow.com/questions/18758402/js-show-hide-text-field-depending-on-radio-button-issue
3.http://bytes.com/topic/javascript/answers/148302-display-hide-fields-using-radio-buttons
4.http://www.chronoengine.com/forums/posts/f26/t95043.html
5.http://arstechnica.com/civis/viewtopic.php?f=20&t=594144
6.http://stackoverflow.com/questions/362614/calling-onclick-on-a-radiobutton-list-using-javascript
7.http://stackoverflow.com/questions/10747521/using-javascript-onclick-to-style-currently-selected-radio-button
8.http://www.dyn-web.com/tutorials/forms/radio.php
9.http://www.codeproject.com/Questions/204763/hide-show-text-box-using-radio-button


I hope this information has been helpful. If this has helped resolve your issue, please let us know by marking the post as ""Best Answer"" to help others in the community with similar questions.