You need to sign in to do that
Don't have an account?
NaypersMclgx
Calendar fields with time range options
Hi everyone!!!, I hope someone can help me with this challenge.
This is the situation...
So, I did something like this...
VISUALFORCE
<apex:page controller="myController"> <apex:form > <apex:selectList id="rangeDates" value="{!selection}" size="1"> <apex:actionSupport event="onclick" action="{!changeDates}" /> <apex:actionSupport event="onclick" reRender="closeDateStart"/> <apex:actionSupport event="onclick" reRender="closeDateEnd"/> <apex:selectOptions value="{!items}"/> </apex:selectList> <br /><br /><br /><br /> <apex:inputField id="closeDateStart" value="{!start.closeDate}" /> <apex:inputField id="closeDateEnd" value="{!end.closeDate}" /> </apex:form> </apex:page>
APEX CODE
public with sharing class myController{ Public string selection{get; set;} Opportunity closeDateStart = new Opportunity(); Opportunity closeDateEnd = new Opportunity(); public Opportunity getStart(){ return closeDateStart; } public Opportunity getEnd(){ return closeDateEnd; } public List<SelectOption> getItems(){ List<SelectOption> optionsDate = new List<SelectOption>(); optionsDate.add(new SelectOption('null','Select Range')); optionsDate.add(new SelectOption('Year','This Year')); return optionsDate; } public void changeDates(){ if(selection == 'Year'){ closeDateStart.closeDate = date.newInstance(2012, 1, 1); closeDateEnd.closeDate = date.newInstance(2010, 12, 31); } } }
But, we have a problem...
What could be the problem??
Thanks for your time!
Hi,
You need to retender those fields in “onclick” on same action.
All Answers
Hi,
You need to retender those fields in “onclick” on same action.
Hi
Try with below code
<apex:page controller="myControllercustomtime">
<apex:form >
<apex:selectList id="rangeDates" value="{!selection}" size="1">
<apex:actionSupport event="onclick" action="{!changeDates}" reRender="datechange"/>
<apex:selectOptions value="{!items}"/>
</apex:selectList>
<br /><br /><br /><br />
<apex:outputpanel id="datechnage">
<apex:inputField id="closeDateStart" value="{!start.closeDate}" />
<apex:inputField id="closeDateEnd" value="{!end.closeDate}" />
<apex:outputpanel>
</apex:form>
</apex:page>
Thanks guys, EXCELLENT SOLUTIONS!, thanks for your help and your time.
Hi
Welcome. If you have any questions really this is the right place to post your questions will get excellent awesome answers.