Controller Code :-
public class Sampletest { public String State {get;set;} public String District{get;set;} public Boolean StateBool {get;set;} public sampletest() { State = 'none'; if(State == 'none') { StateBool = true; } } public void StateBool() { if(State != 'none') { StateBool = false; } else { StateBool = true; } } }
Visualforce Page :-
<apex:page controller="Sampletest"> <apex:form > <apex:actionFunction name="changeBoolCall" action="{!StateBool}"/> <apex:pageblock id="pg"> <apex:pageblockSection > <apex:pageblockSectionItem > Select State :- </apex:pageblockSectionItem> <apex:pageblockSectionItem > <apex:selectList value="{!State}" size="1" multiselect="false"> <apex:selectOption itemLabel="--- None ---" itemValue="none"/> <apex:selectOption itemLabel="Karnataka" itemValue="inr"/> <apex:selectOption itemLabel="Rajasthan" itemValue="inr"/> <apex:actionSupport event="onchange" action="{!StateBool}" reRender="pg"/> </apex:selectList> </apex:pageblockSectionItem> <apex:pageblockSectionItem > Enter the District:- </apex:pageblockSectionItem> <apex:pageblockSectionItem > <apex:inputtext value="{!District}" disabled="{!StateBool}"/> </apex:pageblockSectionItem> </apex:pageblockSection> </apex:pageblock> </apex:form> </apex:page>
Screenshot 1 :-
Screenshot 2:-
No comments:
Post a Comment