0

I have 2 choice fields in a list, with the following values

--1 FoodTypes has 5 values (Vegan, Dairy, Meat, Veges, Fruit)

--2 FoodItems has 9 values (Soy, Milk, Cheese, Hamburger, Pork, Brocc, Squash, Apples, Oranges)

What I want to do is overwrite the choice field values for 'FoodItems' column if someone selects 'FoodTypes' of Fruit, and only show the 2 values in 'FoodItems' of Apples + Oranges.

If a users selects Vegan, Dairy Meat or Veges, show all 9 values in 'FoodItems'...we only need FoodTypes==Fruit to pair down the FoodItems choice column.

I've looked at options to change these columns from choice to lookups, but was have dependencies on this list and copies going to other lists.

*** UPDATE : Was able to get this working, but if you mis-select FoodTypes = Fruit...and I meant to select 'Vegan', I still only have the 2 values in FoodItems associated to Fruit.

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script>
        $(function () {
            $('select[title="FoodTypes"]').change(function () {
                var _FoodType = $('select[title="FoodTypes"] :selected').text();
                if (_FoodType == "Fruit") {
                    $('select[title="FoodItems"] option').each(function () {
                        if ($(this).attr('value') == "Apples" || $(this).attr('value') == "Oranges") {                            
                            // do nothing
                        } else {
                            $(this).remove();
                        }
                    });
                }
            })
        })        
    </script>
-1

You can cascade multiple drop-downs using SPCascadeDropdowns().

Follow steps given in below reference to achieve cascading.

Reference:

  1. SPCascadeDropdowns Using SPServices

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.