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
srikanth Gottimukkalasrikanth Gottimukkala 

How to disable picklist value once it has been chosen

How to disable picklist value once it has been chosen in apex page block table.
Chandra Prakash PandeyChandra Prakash Pandey
Hi Srikanth,

You can use javascritpt to do this easily.
Eswar Prasad@Sfdc11Eswar Prasad@Sfdc11
HI Sreekanth,

can see the below code .You will get idea.


------------------------------------Controller-------------------------------------
public class ShowSectionController
{
    public Account acc{get;set;}
    public boolean flag{get;set;}
    public ShowSectionController()
    {
        acc = new Account();
        flag = true;
      
    }
    public void hideSectionOnChange()
    {
        if(acc.married__c == 'Yes')
            flag = false;
        if(acc.married__c == 'No')
            flag = true;
    }
}
-----------------------------------------------------------------------------------------------
---------------------------------------VF page----------------------------------------------
<apex:page controller="ShowSectionController" tabStyle="Account">
  <apex:form >
  <Apex:actionFunction name="hideSection" action="{!hideSectionOnChange}" rerender="pg"/>

      <apex:pageBlock id="pg">
          <apex:pageBlockSection title="Select A">
              <apex:inputField value="{!acc.Married__c}" onchange="hideSection('{!acc.Married__c}')"/>
          </apex:pageBlockSection>
          <apex:pageBlockSection title="Section B" >
             <Apex:inputText label="Name" rendered="{!(!flag)}"/>
          </apex:pageBlockSection>
      
      </apex:pageBlock>
  </apex:form>
</apex:page>
 
srikanth Gottimukkalasrikanth Gottimukkala
My question is like this for example  if i select piklist value x containg values x,y,z in a picklist field in one record in page block table then i want to hide x value in picklist field in next record in page block table using input field tag so that i can select y value in second record, y nad z will be visible to me and x must be hidden. 
Tejpal KumawatTejpal Kumawat
Hello Srikanat,

You need to query on existing records on controller side, describe picklist values & populate picklist values those records are not created in your_option variable.
<apex:selectList id="selectedObject" value="{!your_variable}">
	<apex:selectOptions value="{!your_options}"/>
</apex:selectList>

If this answers your question mark Best Answer it as solution and then hit Like!