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
Vigneshwaran LoganathanVigneshwaran Loganathan 

Need help

Hi Guyz, Hope you can halp.. I attached 3 small screenshots to Explain my problem..

I have created a Visualforce page, and I need to achieve condition like below.. At first I'm checking the checkbox and it shows Screenshot and Additional screen shot section..
User-added image

and When uncheck I has to show my page like Below screenshot,,
User-added image

But with the knowledge I have in Javascript I could only achieve this :( User-added image

My Code
<apex:page standardController="SME_Coaching__c" extensions="smecoachingcontroller" id="page" >
  <apex:form id="form" >
 
 <!--**Java Script**-->
   <script type="text/javascript">
            function ToggleInput(theId)
            {
                var e = document.getElementById(theId);

                if(e != null)
                {
                    e.disabled = (e.disabled ? false : "disabled");
                }
            }

            window.onload = function () { document.getElementById('{!$Component.textInput}').disabled = "disabled"; }

        </script>
		
  <apex:pageblock id="pb" >
      <apex:pageblockSection > 
         <apex:pageblockSectionItem >
              <apex:actionRegion >
                <apex:inputcheckbox onchange="inputDisplay(this,'{!$Component.id1}')" selected="true"/>
              </apex:actionRegion>
           <apex:outputlabel value="Screenshot"/>
        </apex:pageblockSectionItem> 
          <apex:inputfile id="id1" value="{!myfile.body}" filename="{!myfile.name}" />                                       
        <apex:pageblockSectionitem >
         &nbsp;<apex:outputlabel value="Additional Screenshot (Optional)"/>
         </apex:pageblockSectionitem>
        <apex:pageblockSectionitem >         
          <apex:inputfile id="id1" value="{!myfile.body}" filename="{!myfile.name}" />                                    
        </apex:pageblockSectionitem>
  </apex:pageblockSection>
 </apex:pageblock>
</apex:form>  
</apex:page>

Appreciate your help. Thanks,



 
Best Answer chosen by Vigneshwaran Loganathan
Eswar Prasad@Sfdc11Eswar Prasad@Sfdc11
hi vigneshwarn,
just see the code below ,i till bit changes i done in your code,i checked that its working fine go on

visual force:
<apex:page Controller="coachingcontroller" id="page" >
  <apex:form id="form" >
 
 
  <apex:pageblock id="pb" >
      <apex:pageblockSection > 
      <apex:pageblockSectionItem >
         <apex:inputCheckbox value="{!chbox}">
              <apex:actionSupport event="onclick" action="{!chboxaction}"/>
                </apex:inputCheckbox>
           <apex:outputlabel value="Screenshot"/>
        </apex:pageblockSectionItem> 
          <apex:inputfile id="id1" value="{!file1}" filename="{!name1}" rendered="{!file1ren}"/>                                       
        <apex:pageblockSectionitem >
         &nbsp;<apex:outputlabel value="Additional Screenshot (Optional)"/>
         </apex:pageblockSectionitem>
        <apex:pageblockSectionitem >         
          <apex:inputfile id="id1" value="{!file2}" filename="{!name2}" rendered="{!file2ren}"/>                                    
        </apex:pageblockSectionitem>
  </apex:pageblockSection>
 </apex:pageblock>
</apex:form>  
</apex:page>

controller:

public with sharing class coachingcontroller {
  public coachingcontroller(){
  file1ren=false;
  file2ren=false;
  }

    public Boolean file2ren { get; set; }

    public Boolean file1ren { get; set; }

    public Blob file2 { get; set; }

    public String name2 { get; set; }

    public Blob file1 { get; set; }

    public String name1 { get; set; }

    public Boolean chbox { get; set; }

    public PageReference chboxaction() {
    if(chbox==true){
    file1ren=true;
    file2ren=true;
    }
    else{
    file1ren=false;
    file2ren=false;
    }
        return null;
    }

}