You need to sign in to do that
Don't have an account?
lovecrm
Hiding the section based on Picklist value
Hi,
I am having a Picklist with 3 options: None, Commercial and Rolloff.
If None is selected then the below two sections in VF page should be hidden.
If commercial/Roll Off is selected then the below 2 sections should be shown to the user to enter the data.
Anyone please help me doing this.
Appreciate your help.
Thankyou,
Carol
Dear Carol
Can you check with this sample code whether you met the requirement?
VF Page:
Apex code:
-Suresh
All Answers
This sounds like a great use for the standard Record Types, Page Layouts, and Workflow.
When the field changes, have a workflow rule fire. The workflow will perform a field update. It will update the Record Type field.
When the record type is changed, a new page layout will be displayed.
This new page layout has whatever fields / sections you want on it.
This will work great for simple 3 choices, but doesn't scale well.
If you need the potential to add MANY choices, then you may be looking at visualforce.
You can do this with the help of javascript. You can invoke the javascript function for onchange() event and hide and display the section on the basis of your requirements.
Go through the sample code given below :
<apex:selectList value="{!ListProfile}" size="1" onchange="FetchData();" >
<apex:selectOptions value="{!Pickvalues}"></apex:selectOptions>
</apex:selectList>
function fetchdata()
{
if(this.options[this.selectedIndex].text == 'None')
{
document.getElementById('id').style.display = 'none';// Does not show the section.
}
else
{
document.getElementById('id').style.display = 'block';
}
}
Hope this helps.
Dear Carol
Can you check with this sample code whether you met the requirement?
VF Page:
Apex code:
-Suresh
Thankyou Suresh!
It worked well for me.
Thankyou,
carol
Hi
I have three picklist values: A,B,and C.
Based on the value selected, i want to display different blocksections.
I tried to do it, but failed.