1

This my first attempt at creating a VF page using rendered fields.

I have a Pick list called " Product Type" Pick list values are : Chem-protection , Hand protection

If chem-protection is chosen i want the text field called "Product Code" to appear

If Hand protection is chosen i want the text field "Size"to appear.

The code i have created already is :

Any help would be greatly appreciated.

Thank you

<apex:form >
    <apex:pageBlock title="Costing Enquiry Form Edit" mode="detail">
         <apex:pageBlockButtons location="bottom">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
         </apex:pageBlockButtons>

        <apex:pageBlockSection title="Information" columns="2">
            <apex:inputField value="{!Costing_Enquiry_Form__c.Customer_Name__c}" required="false"/>
            <apex:inputField value="{!Costing_Enquiry_Form__c.OwnerId}" required="false"/>
            <apex:inputField value="{!Costing_Enquiry_Form__c.Contact_Name__c}" required="false"/>
            <apex:inputField value="{!Costing_Enquiry_Form__c.Target_Selling_Price__c}" required="true"/>
            <apex:inputField value="{!Costing_Enquiry_Form__c.End_User__c}" required="false"/>
            <apex:inputField value="{!Costing_Enquiry_Form__c.Estimated_Quantity__c}" required="true"/>
            <apex:inputField value="{!Costing_Enquiry_Form__c.Status__c}" required="true"/>
            <apex:inputField value="{!Costing_Enquiry_Form__c.Sample_Required__c}" required="false"/>
            <apex:inputField value="{!Costing_Enquiry_Form__c.Quote_Number__c}" required="false"/>
            <apex:inputField value="{!Costing_Enquiry_Form__c.Customer_is_currently_using_Seen__c}" required="true"/>
            <apex:inputField value="{!Costing_Enquiry_Form__c.Product_Type__c}" required="true"/>
            <apex:inputField value="{!Costing_Enquiry_Form__c.Required_Standards_CE_Markings__c}" required="true"/>
            <apex:pageBlockSectionItem />
            <apex:inputField value="{!Costing_Enquiry_Form__c.Special_Requirements_Comments__c}" required="true"/>
            <apex:pageBlockSectionItem />
            <apex:inputField value="{!Costing_Enquiry_Form__c.Send_to__c}" required="true"/>
        </apex:pageBlockSection>            

    </apex:pageBlock>
</apex:form>

<apex:relatedList list="OpenActivities" />
<apex:relatedList list="ActivityHistories" />
<apex:relatedList list="CombinedAttachments" />

1

You would want to add an actionSupport on the source picklist, and then conditionally render the other values:

<apex:actionRegion renderRegionOnly="false">
  <apex:inputField value="{!Costing_Enquiry_Form__c.Product_Type__c}" required="true">
    <apex:actionSupport event="onchange" />
  </apex:inputField>
<apex:actionRegion>
<apex:inputField value="{!Costing_Enquiry_Form__c.Product_Code__c}" rendered="{!Costing_Enquiry_Form__c.Product_Type__c='chem-protection'}" required="true" />
<apex:inputField value="{!Costing_Enquiry_Form__c.Size__c}" rendered="{!Costing_Enquiry_Form__c.Product_Type__c='hand protection'}" required="true" />

Adjust as you'd like.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.