You need to sign in to do that
Don't have an account?
Sandeep Yadav
Upload files depend on picklist value
Hello everyone,
I want to upload a number of files when I select a value in the picklist.i.e. when I select 2 in picklist then it uploads only two files and so on.
Here is the code what I did to achieve this.
Thanks in advance
I want to upload a number of files when I select a value in the picklist.i.e. when I select 2 in picklist then it uploads only two files and so on.
Here is the code what I did to achieve this.
Thanks in advance
VF Page-- <apex:page standardController="Document" extensions="MyDocuments"> <apex:form > <apex:pageBlock > <apex:selectList value="{!len}" size="1"> <apex:selectOptions value="{!option}"/> <apex:actionSupport event="onchange" action="{!uploadMultiFile}" reRender="lab"/> </apex:selectList> </apex:pageBlock> <apex:pageBlock title="UpLoad A File"> <apex:pageBlockSection id="lab"> <apex:repeat value="{!total}" var="t"> <apex:inputFile value="{!doc.body}" fileName="{!doc.name}"/> </apex:repeat> <apex:commandButton value="Save" action="{!save}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page> --------------------------------------------------------------------------------------------------------------------- Controller-- public class MyDocuments { public document doc {get;set;} public List<selectOption> option {get;set;} public String len {get;set;} public Integer total {get;set;} public MyDocuments(ApexPages.StandardController controller) { doc = (Document)controller.getRecord(); doc.folderId = UserInfo.getUserId(); option = new List<selectOption>(); option.add(new selectOption('','--None--')); for(Integer i=1; i<=10; i++) { option.add(new selectOption('val'+i,string.valueOf(i))); } } public void uploadMultiFile() { if(len == 'val1') { total = 1; } if(len == 'val2') { total = 2; } } }
You can not rerender inputFile using actionsupport, so you have to use javascript for this.
Check below code for your reference and change this as per your requirment.
Hope this will help you. Let me know if it helped or you need any more assistance.
Please mark this is as the solution if it solved your purpose.
Thanks,
Sohan Raj Gupta
All Answers
You can not rerender inputFile using actionsupport, so you have to use javascript for this.
Check below code for your reference and change this as per your requirment.
Hope this will help you. Let me know if it helped or you need any more assistance.
Please mark this is as the solution if it solved your purpose.
Thanks,
Sohan Raj Gupta