1

Suppose I have one checkbox and one inputfile (Choose File). The idea is whenever I select/check the checkbox (checkbox value=true) then the ChooseFile (inputfile) will be automatically displayed in my visualforce page. Please Help me for this scenario, I've got the following page code & controller code but it doesn't seem to be working.

<apex:inputCheckbox value="{!option}" >
    <apex:actionsupport event="onclick" action="{!change}" reRender="pg"/>
</apex:inputCheckbox>                

<apex:inputFile value="AttachFile"  rendered="{!bool}"/>



public Boolean option {get;set;}
public Boolean bool {get;set;}
public extHospitals(){
    bool = false;
}
public void change() {
    if(option == true){  
        bool = true; 
    }
    else { 
        bool = false;  
    }
}
  • 2
    It is unclear what you are asking! Give more information about the problem. – Sergej Utko Mar 4 '15 at 15:36
  • suppose i have one checkbox and one inputfile (Choose File). when ever i want to selects/check (checkbox value=true) then automatically the ChooseFile (inputfile) will be populate in my visualforce page. Please Help me for this scenario – Chakry Bellamkonda Mar 4 '15 at 15:50
  • And what is the problem you are facing? Is something wrong with your code, or maybe you are getting some error message? Have you tried something so far? – Sergej Utko Mar 4 '15 at 15:52
  • Visualforce Page <apex:inputCheckbox value="{!option}" > <apex:actionsupport event="onclick" action="{!change}" reRender="pg"/> </apex:inputCheckbox> <apex:inputFile value="AttachFile" rendered="{!bool}"/> Contoller : public Boolean option {get;set;} public Boolean bool {get;set;} public extHospitals(){ bool = false; } public void change() { if(option == true) { bool = true; } else { bool = false; } } – Chakry Bellamkonda Mar 4 '15 at 15:55
  • You better edit your questions text instead of posting the code in a comment. – Sergej Utko Mar 4 '15 at 15:56
0

Try using following code :

 <apex:inputCheckbox value="{!option}" >
     <apex:actionsupport event="onclick" action="{!change}" />
 </apex:inputCheckbox>                
 <apex:actionRegion rendered="{!bool}">
     <apex:inputFile value="AttachFile" />
 </apex:actionRegion>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.