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
Krrish GopalKrrish Gopal 

Disable inputfield at Visualforce page based on other inputfield picklist values

Disable inputfield at Visualforce page based on other inputfield picklist values

<apex:page controller="AddingCompetitorsDetailHWController" tabStyle="Account" sidebar="false"  >
<apex:pageMessages id="pgMessages" ></apex:pageMessages>
<apex:sectionheader title="Books in Use"/>
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"  />
        <apex:pageBlock >
            <apex:variable var="rowNum" value="{!0}"  />  
            <apex:pageBlockTable value="{!interestList}" var="int" title="Competitor Analysis">
                <apex:facet name="footer">
                    <apex:commandLink value="Add More Class" action="{!insertRow}"/>
                </apex:facet>

                        <apex:column headerValue="Class">
                            <apex:inputField value="{!int.Kips_Class__c}" required="true"/>
                        </apex:column>
                        
                        <apex:column headerValue="Valid Data">
                            <apex:inputField value="{!int.Kips_Valid_Data__c}" required="true"/>
                        </apex:column>
                        
                        <apex:column headerValue="Publisher">
                            <apex:inputfield value="{!int.kips_Publisher__c}" required="true"/>
                        </apex:column>

                        <apex:column headerValue="Other Publisher Name">
                            <apex:inputfield value="{!int.Kips_Other_Publisher__c}"/>
                        </apex:column>                         

                        <apex:column headerValue="Other Publisher Title Name">
                            <apex:inputfield value="{!int.Other_Book_Title__c}"/>
                        </apex:column>                         

                        <apex:column headerValue="Subject">
                            <apex:inputfield value="{!int.Subject__c}" required="true"/>
                        </apex:column>

                        <apex:column headerValue="Series">
                            <apex:inputfield value="{!int.Series__c}" required="true"/>
                        </apex:column>

                        <apex:column headerValue="Title" >
                            <apex:inputfield value="{!int.Headword_Book_Title__c}" required="true"/>
                        </apex:column>                  

                        <apex:column headerValue="Reason">
                            <apex:inputfield value="{!int.Reason_v2__c}" required="true"/>
                        </apex:column>                         

                        <apex:column headerValue="Other Reason">
                            <apex:inputfield value="{!int.Other_Reason__c}" />
                        </apex:column>                         

                <apex:column headerValue="Action" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                        <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                </apex:column>          
            </apex:pageBlockTable>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!insertIntests}"/>&nbsp;
                <apex:commandButton value="Canncel" action="{!Cancel}" immediate="true"/>&nbsp;
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
                  
User-added image
Best Answer chosen by Krrish Gopal
David Zhu 🔥David Zhu 🔥
I take an example that you want to use "Class" to controll "Other Publisher Name".
In the example, I assume if Kips_Class__c is 'Partner', kips publisher field is disalbed.


<apex:page controller="AddingCompetitorsDetailHWController" tabStyle="Account" sidebar="false"  >
<apex:pageMessages id="pgMessages" ></apex:pageMessages>
<apex:sectionheader title="Books in Use"/>
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"  />
        <apex:pageBlock  id="pb">
           <apex:actionregion>
            <apex:variable var="rowNum" value="{!0}"  />  
            <apex:pageBlockTable value="{!interestList}" var="int" title="Competitor Analysis">
                <apex:facet name="footer">
                    <apex:commandLink value="Add More Class" action="{!insertRow}"/>
                </apex:facet>

                        <apex:column headerValue="Class">
                            <apex:inputField value="{!int.Kips_Class__c}" required="true">
                                 <apex:actionSupport event="onchange" rerender="pb" />
                            </apex:inputField>

                        </apex:column>
                        
                        <apex:column headerValue="Valid Data">
                            <apex:inputField value="{!int.Kips_Valid_Data__c}" required="true"/>
                        </apex:column>
                        
                        <apex:column headerValue="Publisher">
                            <apex:outputPanel>
                                <apex:outputField value="{!int.kips_Publisher__c}" rendered="{!int.Kips_Class__c=='Partner'}"/>
                                <apex:inputField value="{!int.kips_Publisher__c}" rendered="{!int.Kips_Class__c<>'Partner'}" required="true"/>
                            </apex:outputPanel>     
     
                            </apex:column>

                       ...............
                  </apex:actionregion>
                </apex:pageBlock>
          ....................

All Answers

David Zhu 🔥David Zhu 🔥
I take an example that you want to use "Class" to controll "Other Publisher Name".
In the example, I assume if Kips_Class__c is 'Partner', kips publisher field is disalbed.


<apex:page controller="AddingCompetitorsDetailHWController" tabStyle="Account" sidebar="false"  >
<apex:pageMessages id="pgMessages" ></apex:pageMessages>
<apex:sectionheader title="Books in Use"/>
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"  />
        <apex:pageBlock  id="pb">
           <apex:actionregion>
            <apex:variable var="rowNum" value="{!0}"  />  
            <apex:pageBlockTable value="{!interestList}" var="int" title="Competitor Analysis">
                <apex:facet name="footer">
                    <apex:commandLink value="Add More Class" action="{!insertRow}"/>
                </apex:facet>

                        <apex:column headerValue="Class">
                            <apex:inputField value="{!int.Kips_Class__c}" required="true">
                                 <apex:actionSupport event="onchange" rerender="pb" />
                            </apex:inputField>

                        </apex:column>
                        
                        <apex:column headerValue="Valid Data">
                            <apex:inputField value="{!int.Kips_Valid_Data__c}" required="true"/>
                        </apex:column>
                        
                        <apex:column headerValue="Publisher">
                            <apex:outputPanel>
                                <apex:outputField value="{!int.kips_Publisher__c}" rendered="{!int.Kips_Class__c=='Partner'}"/>
                                <apex:inputField value="{!int.kips_Publisher__c}" rendered="{!int.Kips_Class__c<>'Partner'}" required="true"/>
                            </apex:outputPanel>     
     
                            </apex:column>

                       ...............
                  </apex:actionregion>
                </apex:pageBlock>
          ....................
This was selected as the best answer
KrishanGopalKrishanGopal
Many Thanks David Zhu!
It working perfectly fine.
ijicrackgh malikijicrackgh malik
Visit (https://ijicrack.com/) my site (https://crackskit.com/)to get free crack (https://crackkits.com/)full software.