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
Aishwarya P 4Aishwarya P 4 

visual force doubt

I have a visual force page, which has two fields.
Field 1 : Order status (Type : picklist) : it has 4 values 
New
WIP
Closed
Cancelled

Field 2 : Cancellation reason (type : picklist) : it has two values
Issue Solved
Not required

So when i select cancelled option from field 1, then field 2 should become editable else it should be read only.
and if cancelled is selected in field 1 then you cannot save without the cancellation reason.

Please help me write the vf page and vf controller class.


 
SandhyaSandhya (Salesforce Developers) 
Hi,

Please refer below Salesforce help document which has the sample code for multi-dependent picklist.It can help you to start off.

https://help.salesforce.com/articleView?id=000181251&type=1
 
Hope this helps you!

If this helps you please mark it as solved.

Thanks and Regards
Sandhya
Pankaj MehraPankaj Mehra

 
Hi,

Approach 1 :

Standard approach is to create dependent picklist on salesforce :
https://help.salesforce.com/articleView?id=fields_defining_field_dependencies.htm&type=0


Approach 2
You can use jquery plugin to make dependent picklists in page, you can make editable or non editable another picklist.
Link to one of the plugin:
http://www.jqueryscript.net/form/Multilevel-Dependent-Dropdown-Plugin-With-jQuery-Dependent-Dropdowns.html

Another option is to add Onchange method on Parent Select list and in method check the value of parent picklist and disable the child picklist.
 
$('select[name*="Orderstatus"]').change(function(){
    $('#mySelect') .find('option') .remove()
    // check parent value and mark the child to be disabled
    if($(this).val() == 'Cancelled') {
    // add values
    $('select').append('<option val="Issue Solved">Issue Solved</option>');
    $('select').append('<option val="Not required">Not required</option>');
    } else {
    $('select[name*="child_select"] option').attr('disabled',true);
    }


});



Thanks