+ Start a Discussion
Amer SkroboAmer Skrobo 

How to hide checkbox based on a pickList result

How to hide checkbox based on a result of picklist.

Example: If selection of picklist is = "Standard" the checkbox should be shown othervise checkbox needs to be hidden

kamala swarnalathakamala swarnalatha
Hi,

It cannot be hidden using the picklist values other than coding but am not sure it will achieve in coding other than that it can be not possible.

Hope this Helps!

Thanks,
K.Kamala,
Sweet Potato Tec. 
Sampath SuranjiSampath Suranji
Hi,

Try something like below,
public class devForum6 {
    public string selectedName{get;set;}
    public boolean checked{get;set;}
}

<apex:page controller="devForum6">
    <script>
    function selectChange(selectedVal){
        console.log(selectedVal);
        if(selectedVal=='Standard'){
            var div= document.getElementById('divCheckBox');
            div.style='display:none';
        }
        else{
        	var div= document.getElementById('divCheckBox');
            div.style='display:block';
        }
        
    }
    </script>
    <apex:form >
        <apex:selectList size="1" value="{!selectedName}" onchange="selectChange(this.value)"> 
            <apex:selectOption itemLabel="textVal" itemValue="textVal" />
            <apex:selectOption itemLabel="Standard" itemValue="Standard"/>
            
        </apex:selectList>
        
        <div id="divCheckBox">
            <apex:inputCheckbox value="{!checked}"/>
        </div>
        
        
    </apex:form>
</apex:page>
regards
Sampath