You need to sign in to do that
Don't have an account?

how to enable and disable picklist values based on onclick javascript button.
Hi,
I have one custom object (gpt__DupesPreventor_Setting__c) & it has one picklist field which contains all sObjects in our org (gpt__Enable_Object__c).
I made one custom Visualforce Page & i want to show this picklist values based on javascript onclick button.
When i select a one sObject from this PickList then it enable (& Emidiatly show "Disable " button in front of these selected sObject).
When i click on this "Disable" button, then these perticular records gets "Disable".
Hopes someone from this community, coz i already wasted my two days to reasrech on this specific task.
Anyone Help greatly appreciate.
Thnaks.
SalesforceDeveloper.
Simply you can use $(".option").attr("disabled", "disabled");
.option is the class name of options in selectList which you need to disable.
Hope it will help you.
Please try the below code and let me know if this works for you. If still need modifications do let me know.
<apex:page>
<apex:form id="frm">
<apex:selectList multiselect="false" size="1" id="pkList" >
<apex:selectOptions value="{!accNames}">
</apex:selectOptions>
</apex:selectList>
<apex:commandButton value="dis" onclick="fun();return false;" />
</apex:form>
<script>
function fun (){
document.getElementById('{!$Component.frm.pkList}').disabled = true;
}
</script>
</apex:page>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi