You need to sign in to do that
Don't have an account?
Sanu Verma
how to remove Picklist value on vf page
I have an input text field on vf page where i called custom picklist value. But want to restrict some value on condition. means want to hide some value on condition. but not able to do so.
here is my code:-
and the other one
here is my code:-
<div class="slds-form-element slds-m-around_x-small"> <label class="slds-form-element__label " style="font-size: 14px;font-weight: 600;">Payment Method: </label> <div class="slds-form-element__control"> <apex:inputField styleClass="slds-select optionPaymentMethod" value="{!tempOpportunity.Payment_Method__c}" id = "pmethod" > <apex:actionSupport event="onchange" action="{!dummyCall}" rerender="pnlManualPaymentMethod" /> </apex:inputField> <!--<apex:selectList value="{!tempOpportunity.Payment_Method__c}" size="1" >--> <!-- <apex:selectOptions value="{!methodSelectOptionList}"/>--> <!--</apex:selectList>--> </div> </div>
and the other one
function showPaymentMethod() { var methodType = document.querySelectorAll('[id$ = "pmethod"]') [0]; if(tempOpportunity.AccountId == null){ for(var i = 0; i < methodType.length; i++) { if(methodType.options[i].value == 'Wallet'){ methodType.hide(i); } } } return false;
Since your picklist field is on a Visualforce page, you can use some jQuery magic...
Give your field a unique id.
<apex:inputField value="{!My_Picklist__c}" <strong><font color="#FF0000">id="myPicklist"</font></strong> />
Then, remove the option with the blank value as follows:
<script type="text/javascript" src="<a href="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js" target="_blank" rel="nofollow">https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js</a>"></script>
<script type="text/javascript">
$(document).ready(function() {
$('[id*=<strong><font color="#FF0000">myPicklist</font></strong>] option[value=""]').remove();
});
</script>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha