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
Vivek ChaudhariVivek Chaudhari 

How make Date Field visible when check box is selected using custom controller?

I have following code

VF CODE

<apex:page docType="html-5.0" controller="DateSample">
 <apex:form >
     <apex:pageBlock >
     <apex:pageBlockSection >
         <apex:pageBlockSectionItem >
            <apex:outputText >Select Date</apex:outputText> 
            <apex:input type="date" value="{!dat}" disabled="true" id="date1"/>            
         </apex:pageBlockSectionItem><br/>
         <apex:pageBlockSectionItem >
            <apex:outputText >Select</apex:outputText>
            <apex:inputCheckbox value="{!check}">
            <apex:actionSupport event="onClick" reRender="date1" action="{!visible}"/>
            </apex:inputCheckbox>
         </apex:pageBlockSectionItem>         
     </apex:pageBlockSection>       
     </apex:pageBlock>
 </apex:form>
</apex:page>

What is wrong with is code?...
Best Answer chosen by Vivek Chaudhari
Aditya TopalliAditya Topalli
1. Enclose the <apex:inputType> in an <outputPanel>
2. Use a merge field for disabled (or you can use the rendered attribute too), with a boolean variable whose value would be modified in the action function
3. Rerender the outputPanel

VF Updated
...
<apex:outputPanel id="datePanel">
            <apex:input type="date" value="{!dat}" disabled="{!isdisabled}" id="date1"/>    
</apex:outputPanel>        
....  
<apex:actionSupport event="onClick" rerender="datePanel" action="{!visible}"/>
.......

Apex:
public Boolean isDisabled{get;set;}

.....
//In Constructor
isDisabled=true;
.....
public void visible(){
   isDisabled = false;
}


Thanks,
Aditya

All Answers

Akhil AnilAkhil Anil
Kindly paste the controller code as well. Also, try removing the disabled="true" attribute from the input date tag.
 
Aditya TopalliAditya Topalli
1. Enclose the <apex:inputType> in an <outputPanel>
2. Use a merge field for disabled (or you can use the rendered attribute too), with a boolean variable whose value would be modified in the action function
3. Rerender the outputPanel

VF Updated
...
<apex:outputPanel id="datePanel">
            <apex:input type="date" value="{!dat}" disabled="{!isdisabled}" id="date1"/>    
</apex:outputPanel>        
....  
<apex:actionSupport event="onClick" rerender="datePanel" action="{!visible}"/>
.......

Apex:
public Boolean isDisabled{get;set;}

.....
//In Constructor
isDisabled=true;
.....
public void visible(){
   isDisabled = false;
}


Thanks,
Aditya
This was selected as the best answer
Vivek ChaudhariVivek Chaudhari
Thanks a lot...it worked...
Vivek ChaudhariVivek Chaudhari
What if i want to make a reverse of it. that is when check box is disselected, date field should become invisible..? please suggest...